Scalar vs Non-Scalar UDTs In SQL Server 2005

Published 8 January 5 11:8 AM | GregLow

Was reading Bob Beauchemin's wonderful A First Look At SQL Server 2005 For Developers (written with Niels Berglund and Dan Sullivan) again this morning.

I was particularly interested in his/their opinions on what are good candidates for UDT's in Yukon. In amongst that, I found an interesting discussion on scalar vs non-scalar types and how they might affect your choices. He/they suggest that scalar values are more appropriate than non-scalar ones and provide an interesting example of how that really makes a difference.

A date could potentially be seen as 3 integers and a point could be seen as two but they would work very differently with say a sql BETWEEN clause. Even though a date has three values, it really is just a representation of a linear value and so you can easily use a BETWEEN. That isn't the case for a point.

You could also store a date in a struct (or Structure for VB) rather than a Class, get the advantages of a value tyep and even use binary comparison, as long as you set up the member variables in the right order.