Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

As someone who develops websites and does a bit of SQL Server, it seems a no brainer to me that SQL Server should support a simple clause that indicates the results should only include a specific range of rows. For example, rows 30 through 39.

As it stands, implementing paging in SQL Server is actually a little beyond many web developers' capability when their main focus is not SQL.

In addition, it would greatly simplify queries that may already be complex due to joins and other conditions.

On top of that, I'm of the opinion that such a clause may stand a better chance of getting optimized internally over time because the logic would be entirely under Microsoft's control.

I brought this up some time ago in another forum and many of the replies seemed to suggest this would not be desirable.

Given that any existing techniques for paging would be left intact, what possible reason could there be for not adding such a clause? And it would be so much better for people like me.

Can anyone thing of a good reason why Microsoft hasn't done this?

share|improve this question
add comment

2 Answers 2

up vote 8 down vote accepted

Microsoft has done this with the next version of SQL Server, codename "Denali", as well as SQL CE 4. Check out the OFFSET & FETCH parts of the ORDER BY clause here: http://msdn.microsoft.com/en-us/library/ms188385(v=sql.110).aspx

share|improve this answer
    
Well, it's not exactly as simple as I imagined but I'll take it! And I'm very happy to hear that I'm not the only person who agrees this is worthwhile. I eagerly await the arrival of the next version! Thanks. –  Jonathan Wood Jan 24 '11 at 1:14
add comment

At this moment SET ROWCOUNT, TOP(), and ROW_NUMBER() can help you :)

Here is some sample from SO

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.