mssql how to get the previous row and next row value using select statement Edit

Murugan Andezuthu Dharmaratnam | 27 November 2020 | 1128

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