• Brandie Tarvin (1/27/2015)


    WayneS (1/27/2015)


    Brandie Tarvin (1/27/2015)


    Excuse me while I stand over in my corner gloating that I figured something out all by my lonesome without looking anything up. YES!

    Congrats Brandie. That sure is a great feeling.

    BTW, are you using SQL 2012? If so, check out the LEAD function for getting the gap even easier.

    We are about to move to SQL 2012, so I will check out the LEAD function. Thanks, Wayne.

    LEAD (or LAG) both provide quite intuitive methods for find gaps I agree. I'm just a little surprised you'd recommend them given the performance characteristics:

    SQL Server 2012 Performance Test: Gap Detection[/url]

    Although at times the simplest solution may be good enough.

    There are many traditional and non-traditional methods for finding gaps:

    The SQL of Gaps and Islands in Sequences[/url]


    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