November 14, 2015 at 11:23 pm
Comments posted to this topic are about the item Nested Types
November 14, 2015 at 11:24 pm
Good question, learned somthin new 2day, keep up these kind of questions, thanx 🙂
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
November 16, 2015 at 12:53 am
good question. Thanks for sharing.
November 16, 2015 at 5:28 am
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.
November 16, 2015 at 9:16 am
Simple and nice - thanks, Steve!
November 16, 2015 at 11:23 pm
This was removed by the editor as SPAM
November 16, 2015 at 11:41 pm
Good question, dismissed the correct answer after thinking about he batch option ;-), thanks Steve
...
November 17, 2015 at 4:54 am
Nice one, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
November 17, 2015 at 5:02 am
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
November 23, 2015 at 2:16 pm
Thanks for the question.
November 24, 2015 at 7:39 am
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