mssql how to get the previous row and next row value using select statement Edit
you can use the LAG and LEAD function to get the previous and next row in SQL server while using the select statment
Solution
select LAG(Id) OVER (ORDER BY DisplayOrder) PreviousId,Id, LEAD(Id) OVER (ORDER BY DisplayOrder) NextId, DisplayOrder,ImageId from ItemImageMapping where ItemId = @ItemId