Nested Types

  • Comments posted to this topic are about the item Nested Types

  • Good question, learned somthin new 2day, keep up these kind of questions, thanx 🙂

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • good question. Thanks for sharing.

  • I've never had to use user-defined types in the database before, so I learned something new. I think I knew this because of the reading I did from last week's question on custom types. Thanks, Steve.

  • Simple and nice - thanks, Steve!

  • This was removed by the editor as SPAM

  • Good question, dismissed the correct answer after thinking about he batch option ;-), thanks Steve

    ...

  • Nice one, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Nice simple question.

    But although it is nice and simple and it's easy to see which option is intended to be correct, pedantically speaking perhaps none of them is correct - the three wrong answers simply because they are wrong and the "right" answer because "email" (according to the CREATE TYPE BOL page) is not a UDT (UDTs are based on CLR assemblies, not on base types), it's a type alias, so the reason the second create type statement fails has nothing to do with UDTs - the reason it fails is that nothing but the 28 base types (sysname is not a base type, it's a type alias) can be used as the base for a type alias . Of course user-created type aliases appear in sys.types flagged is-user-defined, so there seems to be some confusion even within Microsoft as to whether type aliases (other that MS-defined ones like systype) are UDTs or not.

    edit: 10 minutes after posting it suddenly clicked that type aliases are sometimes called "User Defined DataTypes" and the CLR-based types are always "User Defined Types" - maybe the MS terminology for this stuff is even more confused that I thought.

    Tom

  • Thanks for the question.

  • I ran this and got the below error.

    The base type "email" is not a valid base type for the alias data type.

    Never had a reason personally to create types, but have been in existing DBs where they exist. Good to know if I ever need to use them.

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply