• SanDroid (7/5/2011)


    This was done in a single script, but not a single query.

    The insert into the #temp table is executed as a sperate query.

    You would need to start with the use of a WITH table statement, or a derived table to get this done to a single query.

    Interesting way to resolve a bad table design issue without correcting the bad table design.

    At times you have to work with less than perfect data even if it's no fault of your own.

    Also, in my estimation, the "single query" push is a little overrated. What's the advantage of a single query? Performance can be enhanced in some cases with more than one query. So performance itself can't always be the answer.

    The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking