May 2005 Blog Posts

  • 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.  RDBMS : “What are you INSERTing Dave?” Dave: “I don't know!“ RDBMS : “Get stuffed!” Anyway I am knocking out a stored proc that returns “Quick Stats” to the client.  Basically just UNIONing.. USE PUBSGOSELECT 'Sales Count' as Stat, COUNT(*) as ScoreFROM  salesUNION ALLSELECT 'Title Count', COUNT(*) FROM titles Too easy...But a request comes to include a “Last Date” statistic... SELECT 'Sales Count' as Stat, COUNT(*) as ScoreFROM salesUNION ALLSELECT 'Last Published',  MAX(pubdate) FROM titles “So we sold...