我有一个关于存储过程的问题。
我尝试获取一页结果集和整个集的记录数。
每一个都是独立的,但我无法将它结合起来:
ALTER PROCEDURE dbo.pagingSCP
@PageStart INT,
@PageSize INT,
@RecordCount INT OUTPUT
AS
BEGIN
WITH AllRecords AS (
SELECT ROW_NUMBER() OVER (ORDER BY MATNR)
AS Row, viewStyleColorInModul.*
FROM viewStyleColorInModul WHERE SPRAS = 'D'
) SELECT * FROM AllRecords WHERE Row between
@PageStart and @PageStart + @PageSize
END
(返回 50 行)@RecordCount = 0 @RETURN_VALUE = 0 完成运行 [dbo].[pagingSCP]。
ALTER PROCEDURE dbo.pagingSCP
@PageStart INT,
@PageSize INT,
@RecordCount INT OUTPUT
AS
BEGIN
WITH AllRecords AS (
SELECT ROW_NUMBER() OVER (ORDER BY MATNR)
AS Row, viewStyleColorInModul.*
FROM viewStyleColorInModul WHERE SPRAS = 'D'
) SELECT @RecordCount = Count(*) From AllRecords
END
没有行受到影响。(0 行返回)@RecordCount = 43770 @RETURN_VALUE = 0 完成运行 [dbo].[pagingSCP]。
现在是否有可能在单个查询中获得 50 行和总记录数?
提前致谢。