Home Forums SQL Server 2005 T-SQL (SS2K5) Is this a "gaps and islands" problem? Finding gaps in overlapping times. RE: Is this a "gaps and islands" problem? Finding gaps in overlapping times.

  • GPO (8/15/2013)


    Edit: I think I get it now! The cross joins mean that 10^5 rows are generated, and you're saying it's irrelevant that 5 meaningless columns just happen to be generated. Doing an extra CROSS JOIN would presumably result in 6 meaningless columns and a million rows. Does that sound right?

    Edit 2:

    a readless Tally Table

    So that means a tally table that doesn't have to be read from the disk, and is presumably therefore faster than the permanent tally table I usually use. How am I going so far?

    Seems that your edit was on the mark.

    Here's a link you can look at that is comparing in-line vs. disk tally tables. The result I'd say is that it depends.

    http://www.sqlservercentral.com/scripts/tally/100338/

    I believe the comparison code is in an attached resource file.


    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