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