Offsetting rows in SQL Server

351845 pts.
Tags:
SQL Server
How can I use SQL Server to provide results starting at a given offset? For example, in another SQL server, it's possible to do:

SELECT * FROM MyTable OFFSET 50 LIMIT 25

to get results 50-74. This construct does not appear to exist in SQL Server.

Is there a way to do this where only the rows I am working on get loaded?


Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    What version of SQL Server?  I believe it has been added in SQL Server 2012.
    70,180 pointsBadges:
    report
  • ITKE
    Yes Carlos, we're using SQL Server 2012.
    351,845 pointsBadges:
    report
  • carlosdl
    Great, you should be able to do something like this:

    SELECT *
    FROM MyTable
    ORDER BY someColumn
    OFFSET 50 ROWS
    FETCH NEXT 25 ROWS ONLY;

    70,180 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following