麻烦高手帮我看看这个存储过程有什么问题 连接的是Northwind数据库
怎么解决 :"递归公用表表达式'customers'不包含顶级union all运算符":
create PROCEDURE P_GetPagedOrde
@startIndex INT,
@pageSize INT
AS
begin
with customers as
(
SELECT ROW_NUMBER()
OVER (ORDER BY customerid DESC)AS Row,companyname,contactname,contacttitle,address,city
from customers
)SELECT customerid,companyname,contactname,contacttitle,address,city
FROM customers
WHERE Row between @startIndex and @startIndex+@pageSize-1
end
怎么解决 :"递归公用表表达式'customers'不包含顶级union all运算符":
create PROCEDURE P_GetPagedOrde
@startIndex INT,
@pageSize INT
AS
begin
with customers as
(
SELECT ROW_NUMBER()
OVER (ORDER BY customerid DESC)AS Row,companyname,contactname,contacttitle,address,city
from customers
)SELECT customerid,companyname,contactname,contacttitle,address,city
FROM customers
WHERE Row between @startIndex and @startIndex+@pageSize-1
end
(
SELECT ROW_NUMBER()
OVER (ORDER BY customerid DESC)AS Row,companyname,contactname,contacttitle,address,city
from customers
)
有问题 customers 改为customers1吧
@startIndex INT,
@pageSize INT
AS
begin
with liang as
(
SELECT ROW_NUMBER() OVER (ORDER BY customerid DESC) AS Row,
customerid,
companyname,contactname,contacttitle,address,city
from [customers]
) SELECT customerid,companyname,contactname,contacttitle,address,city
FROM liang
WHERE Row between @startIndex and @startIndex+@pageSize-1
end
@startIndex INT,
@pageSize INT
AS
begin
with liang as
(
SELECT ROW_NUMBER() OVER (ORDER BY customerid DESC) AS Row,
customerid,
companyname,contactname,contacttitle,address,city
from [customers]
) SELECT customerid,companyname,contactname,contacttitle,address,city
FROM liang
WHERE Row between @startIndex and @startIndex+@pageSize-1
end