We have to use Limit keyword in SQL server 2008/2012.
We need to apply limit for every query where start index will change every time. When I was googling found TOP but it won't work for us. Can anyone please share how to use LIMIT keyword in sql server where every time start index change.
We need query in SQL server like below -
SELECT * from STOCK LIMIT 11, 10000 (where 11=start index, 10000=size)
You could use a CTE with a window function, like in the answer to this SO question -> Skip first row in SQL Server 2005?
We have upgraded to SQL server 2012 and replaced query with OFFSET and FETCH. Sample is below.
You would have to use something like the
ROW_NUMBER()
function and then specify what you want from there.This is probably not a good long-term solution for you, but if the table has an Identity field you could do something like this: