SQL Server 2008中的分页 [英] pagination in SQL server 2008

查看:81
本文介绍了SQL Server 2008中的分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是SQL Server的新手.保留问题作为参考.我的疑问是
为什么Microsoft Sql Server在Mysql中没有限制,现在它们被迫编写SP或内部查询以进行分页.我认为创建临时视图/表或使用内部查询将会比简单的查询要慢.我相信有很强的理由不赞成这样做.我想知道原因.

I am a newbie to SQL server. keeping this question as reference.My doubt is
why Microsoft Sql server doesn't have something like limit in Mysql and now they are forcing to write either SP or inner query for pagination.I think creating a temporary view/table or using a inner query will be slower than a simple query.And i believe that there will be a strong reason for deprecating this. I like to know the reason.

如果有人知道,请分享.

If anyone know it please share it.

推荐答案

我从不知道SQL Server支持像TOP 10,20这样的东西-您真的完全确定吗?可能不是其他系统吗?

I never knew SQL Server supported something like TOP 10,20 - are you really totally sure?? Wasn't that some other system maybe??

无论如何:SQL Server 2011(代号为"Denali")将在2011年底左右发布时对此提供更多支持.

Anyway: SQL Server 2011 (code-named "Denali") will be adding more support for this when it comes out by the end of 2011 or so.

ORDER BY子句将获得新的其他关键字OFFSETFETCH-有关它们的更多信息

The ORDER BY clause will get new additional keywords OFFSET and FETCH - read more about them here on MSDN.

您将能够编写如下语句:

You'll be able to write statements like:

-- Specifying variables for OFFSET and FETCH values  
DECLARE @StartingRowNumber INT = 150, @FetchRows INT = 50;

SELECT 
    DepartmentID, Name, GroupName
FROM 
    HumanResources.Department
ORDER BY 
    DepartmentID ASC 
    OFFSET @StartingRowNumber ROWS 
    FETCH NEXT @FetchRows ROWS ONLY;

这篇关于SQL Server 2008中的分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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