I have a table and I need to retrieve the ID of the Second row. How to achieve that ?
By Top 2
I select the two first rows, but I need only
Select top 2 [id] from table Order by [id] desc
should give you want you the latest two rows added.
However, you will have to pay particular attention to the order by
clause as that will determine the 1st and 2nd row returned.
If the query was to be changed like this:
Select top 2 [id] from table Order by ModifiedDate desc
You could get two different rows. You will have to decide which column to use in your order by statement.