存储过程,但我还没有弄清楚如何使用T-Sql [英] stored procedure but I have not figured out how to do so using T-Sql

查看:66
本文介绍了存储过程,但我还没有弄清楚如何使用T-Sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用SQL Server 7.0的Web应用程序,它返回查询页面的结果。由于查询可以返回数千行,因此我一次只显示50个速度。然后用户点击下一个箭头以显示行51-100。我希望能够在存储过程中完成所有这些但我还没有想出如何使用Sql这样做。我知道前50名,但在接下来的50或接下来的50后,这对我没有帮助。我已经难倒了几个DBA这里可以帮忙吗?

I have a web application using SQL Server 7.0 that returns the results of a query page. Since a query could return thousands of rows I only display 50 at a time for speed. The user then hits the next arrow to display rows 51 - 100. I would like to be able to do all of this in a stored procedure but I have not figured out how to do so using Sql. I know about the Top 50 but that doesn't help me with the next 50 or the next 50 after that. I have stumped several DBAs with maybe Here can help?

推荐答案

有几种方法。

试试这个:

There are a couple of ways.
Try this:
WITH myTableWithRows AS (
    SELECT (ROW_NUMBER() OVER (ORDER BY myTable.SomeField)) as row,*
    FROM myTable)
SELECT * FROM myTableWithRows WHERE row = BETWEEN 50 AND 99


这篇关于存储过程,但我还没有弄清楚如何使用T-Sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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