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+'%'''
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
执行结果为
<ignore_js_op>
去掉 (where FImagDescribe like N'''%'+@strKey+'%''') 后 select @RowCount =COUNT(FCaseChildId),@PageCount=CEILING((COUNT(FCaseChildId)+0.0)/@PageSize) FROM TCaseContent
结果为
<ignore_js_op>
为什么我加where后输出参数不能用了呢??什么情况??????
额...熬夜太晕了...多了分号居然不知道where FImagDescribe like N'''%'+@strKey+'%''' 改为like N'%'+@strKey+'%'这样就解决了