I’ve seen quite a few really horrid ways to do something like MySQL’s LIMIT function for MS SQL.
Can anyone suggest a nice elegant way to do something like this:
SELECT * FROM blah LIMIT 5,15;
but in MS SQL?
Cheers!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
SQL Server’s equivalent to MySQL/PostgreSQL’s LIMIT syntax is TOP (SQL Server 2000+), but TOP doesn’t support the offset value…
Assuming SQL Server 2005+, use:
Mind that you have to define a sort order for the ranking – replace the “?” with the appropriate column(s).