• sjsubscribe (8/30/2012)


    Dwain, works perfectly. Thanks very very much.

    First off, I never thought about quirky update though I used it before.

    Second, your code ran in 5.1 seconds for 300K records on SQL 2012. Impressive.

    --S.J.

    SJ - Glad it worked for you.

    I must say, you led me down the garden path suggesting it was gaps and islands. Maybe it is but I couldn't figure it from that perspective. Once I realized QU would work, it didn't take long to get it working.

    Eugene - I'm not sure I understand what you mean. I mean I get the part saying that the 3 part SET might not be reliable. But can you demonstrate a working solution using a 2 part SET?


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St