Reputation: 5041
I am trying to select rows in SQL Server 2012, I want to select from row x to row y.
Is there an option in SQL Server to select rows from-to like in mysql limit 10,20?
Upvotes: 0
Views: 109
Reputation: 2744
SELECT * FROM TableName
OFFSET 0 ROWS -- Starting Row Number
FETCH NEXT 10 ROWS ONLY; -- Number of rows you want
Upvotes: 1
Reputation: 1269923
You are looking for the offset
/fetch
functionality.
The documentation is here.enter link description here
This is new in SQL Server 2012, so you need other methods in earlier versions of SQL Server, such as using row_number()
or using nested queries with top
.
Upvotes: 2