Skip to content
Advertisement

why I’m not able to use LIMIT and OFFSET in SQL Server stored procedure

I am trying to get MAX – 1 record using below query but if I use LIMIT and OFFSET in query it is throwing error. Any other way can use this query to get Max – 1 row? I am using SQL Server

Advertisement

Answer

This is the exact syntax you should use for your inner select:

And then your update statement will be like this:

Here is a small demo

P.S. SQL Server does not have LIMIT, you can use TOP or OFFSET with FETCH NEXT. If you want to use TOP you can not use the offset to start from second result or third result.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement