• Interesting discussions so far!

    I guess I was swayed by the opinions of others in this thread over the usefulness of UDTs but now I can see why you'd want them. Basically a UDT is no different than say a DateTime type, for example. Internally this is stored as a number but because it's a specialized type it has its own operations, like DateDiff, and operators can act differently when there are DateTime operands involved. With a DateTime type if you add two together using the + operator you get a new DateTime. For instance if you execute this

    select

    cast('1/1/2007' as datetime) + cast('2/1/2007' as datetime)

    you get the DateTime 2/1/2114, but if you execute this

    select

    '1/1/2007' + '2/1/2007'

    you get the string '1/1/20072/1/2007'. Basically the + operator is overloaded in OO lingo.

    So for a UDT you could have the AddressLine type mentioned earlier in the thread and it would have its own operations, like DistanceFrom, and operators can behave differently with it. Perhaps the + operator would be invalidated so if you tried to add two together you'd get an error. The value of a UDT is determined by the person inventing / using it. The built-in types of SQL Server are just types generally thought to be useful, that's not to say an application can't find a value in using another type. For instance, treating a string not as a string but as a date.