Pergunta

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?

Foi útil?

Solução

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

Outras dicas

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

Here is some sample from SO

Licenciado em: CC-BY-SA com atribuição
Não afiliado a dba.stackexchange
scroll top