时间:2021-07-01 10:21:17 帮助过:19人阅读
sqlserver2005中的万能分页存储过程。建立主表临时表 CREATE TABLE #temp(rownumber bigint,orderseqno VARCHAR(36),goodsname VARCHAR(50),companyname VARCHAR(100))建立子表临 时表CREATE TABLE #detail(orderseqno VARCHAR(36),detailid UNIQUEIDENTIFIE
sqlserver2005中的万能分页存储过程。–建立主表临时表
CREATE TABLE #temp
(
rownumber bigint,
orderseqno VARCHAR(36),
goodsname VARCHAR(50),
companyname VARCHAR(100)
)
–建立子表临 时表
CREATE TABLE #detail
(
orderseqno VARCHAR(36),
detailid UNIQUEIDENTIFIER,
unitprice DECIMAL(12,2),
Qty int
)
–插入主表数据到主表临时表
insert into #temp
SELECT oo.rownumber, oo.OrderSeqNO, oo.GoodsName, oo.CompanyName FROM
(SELECT ROW_NUMBER () OVER (ORDER BY oi.createdate DESC) AS rownumber,
oi.OrderSeqNO, oi.GoodsName ,ci.CompanyName
FROM OrderInfo oi INNER JOIN CompanyInfo ci ON oi.CompanyID=ci.CompanyID
WHERE oi.CreateDate