Lynn Pettis (11/27/2008)
Since the purpose of the identity field was order, if there was a gap it wouldn't have caused an issue.
Hi Lynn,
But you are using the IDENTITY values for more than just imposing an order. You use "WHERE B.ID BETWEEN A.ID - 4 AND A.ID" to find the current and four preceeding rows - but if there are gaps, then less than four preceeding rows will match this clause.