• Jeff Moden (10/7/2012)


    dwain.c (10/7/2012)


    I don't think this has the same issue that Jeff is reporting about Mark's but it's just another option:

    Gosh. Good bit of code, Dwain, but it also has a full cross join in it according to the actual execution plan. Again, I don't know if these things will "convert" to something else if the row count gets bigger or not. Guess I'll have to give it a try.

    I'm really interested in this problem because I normally use the Quirky Update for "data smears" like this and I'd love to see a different method that didn't end up with a cross join in it.

    Hmmm. I looked for that but it must have escaped my notice.

    I did have a recursive CTE solution (gone now) but I expected it would be a dog so didn't post it.

    I thought about a QU but didn't quite figure how it could be used to create additional records. Perhaps a Quirky Merge?

    In any event, I am most curious what you come up with...


    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