Wednesday, May 11, 2005

A usage for SQL_Variant?

SQL_Variant.. Finally a use for it...

"The 'object' type of SQL Server is hardly used and with good reason. RDBMS are meant to be 'strongly typed'.. it is the foundation of the domain/type concept

...

'But wait, I have a better idea..'

SELECT 'Sales Count' as Stat, CAST(COUNT(*) AS SQL_VARIANT) as Score
FROM sales
UNION ALL
SELECT 'Last Published', MAX(pubdate)
FROM titles"


Now isn't that an interesting thought?

I've stayed pretty far away from SQL Variants (I don't think I've ever used them... that's pretty far away). I just didn't see where they would really help me much verses the possible risks (brand new data type in SQL 2K, they're variants... etc, etc).

I have tables with VARCHAR columns where I coerce the data to/from strings, which is the place that seems SQL variants would be logical. But still.. they seem, I don't know... horky? In VB we've been turned away from variants for so long, that going back to them in SQL just doesn't feel right.

Still, maybe it's time to take another look at that data type...

No comments:

Post a Comment

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...