How to get prev and next record from a selection

  • Remember, your CTE is going to go through the entire table to get the row numbers and then again to get them for the previous ID and then again to get the next ID.

    The subquery is likely going to do a seek if the index is available.

    I'm guessing at the execution plan and, as always in SQL Server, it depends.

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

Viewing post 16 (of 15 total)

You must be logged in to reply to this topic. Login to reply