in MySQL we use LIMIT
and in sql server we must use TOP
instead of LIMIT
,but we can use LIMIT
in the this way:
Limit X, Y
which X is the starting point and Y is duration.
now how can i use TOP
like that example?
in MySQL we use LIMIT
and in sql server we must use TOP
instead of LIMIT
,but we can use LIMIT
in the this way:
Limit X, Y
which X is the starting point and Y is duration.
now how can i use TOP
like that example?
you can use ROW_NUMBER() function , with CTE (Common table Expression)
with cte as(
select *,ROW_NUMBER() over (order by col1) as rownumber from <table>)
select * from cte where rownumber between x and y
You can't before SQL Server 2012 which added FETCH..OFFSET
So you need to "page" using ROW_NUMBER function. Examples: