如何在SQL Server 2005中使用LIMIT [X]偏移[Y] [英] How to use LIMIT [X] OFFSET [Y] with SQL Server 2005

查看:58
本文介绍了如何在SQL Server 2005中使用LIMIT [X]偏移[Y]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
是否等同于SQL Server的LIMIT和OFFSET?

Possible Duplicate:
Equivalent of LIMIT and OFFSET for SQL Server?

如何在SQL Server 2005中使用LIMIT [X]偏移[Y],我看到mysql,oracle,sqllite,postgre拥有它,microsoft没意识到我们需要它吗?

How to use LIMIT [X] OFFSET [Y] with SQL Server 2005, i see mysql, oracle, sqllite, postgre have it, microsoft dont realize we need it ?

推荐答案

Microsoft(可能会说要进行更改)选择实现ANSI标准,而不是提出自己的专有关键字(例如LIMIT).在下一版本的SQL Server(代号为"Denali")中,您将可以使用

Microsoft (for a change, you might say) chose to implement the ANSI standard instead of coming up with their own proprietary keyword like LIMIT. In the next version of SQL Server (code-named "Denali") you will be able to use OFFSET / FETCH.

同时,您将需要对SQL Server使用不同的方法(或者,如果您认为这比其他类型的输入要容易的话,请切换平台).一篇关于现有版本中几种分页方法的好文章在这里:

In the meantime, you will need to use different methods with SQL Server (or switch platforms if you think that is easier than extra typing). A good article about a few methods for paging in existing versions is here:

http://www.sqlservercentral.com/articles/T-SQL/66030 /

请确保单击加入讨论",以阅读60多个后续评论,其中讨论了所提供解决方案的各个方面.

Be sure to click on "Join the Discussion" to read over the 60+ follow-up comments that discuss various aspects of the solutions provided.

请注意,出于性能考虑,未实现OFFSET/FETCH;仅用于生产力.换句话说,OFFSET/FETCH的性能与今天通常使用的ROW_NUMBER()解决方案几乎相同.

Note that OFFSET / FETCH is not implemented for performance reasons; only for productivity. In other words, OFFSET / FETCH will perform about the same as the ROW_NUMBER() solutions typically in use today.

编辑尽管有些人已经证明了Denali在首页上表现更好的情况(例如

EDIT While some have demonstrated cases where Denali performs better on the first page (eg http://mssqltips.com/tip.asp?tip=2420), this is not the intention, and I'm not convinced the delta remains true as you traverse the table and get to the latter pages (particularly on large tables).

这篇关于如何在SQL Server 2005中使用LIMIT [X]偏移[Y]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆