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
Top 2
I have a much easier way than the above ones.
DECLARE @FirstId int, @SecondId int SELECT TOP 1 @FirstId = TableId from MyDataTable ORDER BY TableId SELECT TOP 1 @SecondId = TableId from MyDataTable WHERE TableId <> @FirstId ORDER BY TableId SELECT @SecondId