如何在sql server中显示选中的行? [英] How to display selected row in sql server?

查看:164
本文介绍了如何在sql server中显示选中的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表格中有很多数据。我想在html表中显示前20行。当我点击下一步然后将显示下一行20行。是否有任何存储过程有两个参数,起始索引和结束索引..两个参数之间的数据将显示????????????

解决方案

 声明  @ pageSize   int  =  20  
声明 @page int = 5

; 数据
as

选择 row_number() over order by modifieddate) as rowNo,salesOrderId,UnitPrice,OrderQty from Sales.salesorderdetail


选择 * 来自数据其中 rowNo> =( ( @ page - 1 )* @ pageSize rowNo< ( @ page * @ pageSize );





来自这个 [ ^ ]文章,其中我今天才发布。


如果您使用的是MS SQL 2012,则会有一个新的OFFSET-FETCH关键字,可以在ORDER BY之后应用。



SQL中的新T-SQL功能Server 2012 - OFFSET和FETCH - 更多信息请参见:http://dbadiaries.com/new-t-sql-features-in-sql-server-2012-offset-and-fetch#sthash.UwvkIl1k.dpuf [ ^

I have lots of data in my table. I want to display first 20 rows in html table. when i click next then next 20 rows will be displayed. is there any stored procedure with two parameters, start index and end index.. and data in between both parameter will be displayed???????????

解决方案

declare @pageSize int = 20
declare @page int = 5

;with data
as
(
select row_number() over (order by modifieddate) as rowNo, salesOrderId, UnitPrice, OrderQty from Sales.salesorderdetail
)

select * from data where rowNo >= ((@page - 1) * @pageSize) and rowNo < (@page * @pageSize);



From this[^] article, which I only published today.


If you are using MS SQL 2012, there is a new OFFSET-FETCH keywords, that can be applied after ORDER BY.

New T-SQL features in SQL Server 2012 – OFFSET and FETCH - See more at: http://dbadiaries.com/new-t-sql-features-in-sql-server-2012-offset-and-fetch#sthash.UwvkIl1k.dpuf[^]


这篇关于如何在sql server中显示选中的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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