SQL SERVER 2000里怎么实现这个功能
/*
在SQL SERVER 2005里有一个要用到ROW_NUMBER() 的存储过程,ROW_NUMBER()在SQL SERVER 2000里是没有的,但不幸的是我们公司是用的SQL SERVER 2000,怎么改才能达到相同功能呢?
*/
CREATE PROCEDURE dbo.GetProductsPaged
(
@startRowIndex int,
@maximumRows int
)
AS
SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued, CategoryName, SupplierName
FROM
(
SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued,
(SELECT CategoryName
FROM Categories
WHERE Categories.CategoryID = Products.CategoryID) AS CategoryName,
(SELECT CompanyName
FROM Suppliers
WHERE Suppliers.SupplierID = Products.SupplierID) AS SupplierName,
ROW_NUMBER() OVER (ORDER BY ProductName) AS RowRank
FROM Products
) AS ProductsWithRowNumbers
WHERE RowRank > @startRowIndex AND RowRank <= (@startRowIndex + @maximumRows)
------解决方案--------------------可以考虑用临时表,比如:
use pubs;
select identity(int,1,1) as rownumber,name,colorder into #t from syscolumns;
select * from #t;
------解决方案--------------------如楼上, 考虑临时表吧.
或者在程序中处理分页.