ALTER PROCEDURE [dbo].[GetCaseContentPageDataOutRowPageCount2]
(
@PageIndex int = 1,--当前页数
@PageSize int = 4,--每页大小
@strKey nvarchar =N'a',
@RowCount int output,--总行数(传出参数)
@PageCount int output--总页数(传出参数)
)
AS
begin
DECLARE @sql NVARCHAR(max)
select @RowCount =COUNT(FCaseChildId),@PageCount=CEILING((COUNT(FCaseChildId)+0.0)/@PageSize) FROM TCaseContent where FImagDescribe like (N'''%'+@strKey+'%''') 错误的 应改为N'%'+@strKey+'%'
SET @sql='SELECT TOP '+LTRIM(str(@PageSize))+' * FROM TCaseContent where FImagDescribe like N'+'''%'+@strKey+'%'''+' and FCaseChildId not in(select top '+LTRIM(str((@PageIndex-1)*@PageSize))+' FCaseChildId from TCaseContent where FImagDescribe like N'+'''%'+@strKey+'%'' )'
print @sql
EXEC(@sql)
end
declare @RC int,@Pc int
exec GetCaseContentPageDataOutRowPageCount2 1,10,N'e',@RC output,@PC output
select @RC,@PC
执行结果为