ALTER PROCEDURE Proc_MemorialHall_SeconSide @Keyword nvarchar(100)=‘‘, @BeginPage int , @PageCount int, @RecordCount int output AS BEGIN SET NOCOUNT ON; declare @BeginIndex int=((@BeginPage-1)*@PageCount)+1 declare @EndIndex int=(@BeginPage*@PageCount) declare @sql nvarchar(2000) declare @sqlCount nvarchar(2000) declare @condition nvarchar(100)=‘‘ if(LEN(@Keyword)>0) begin set @condition=‘ and mh.Title like ‘‘%‘+@Keyword+‘%‘‘‘ end set @sql=‘select * from(select mh.*,ROW_NUMBER() over(order by BuildDateTime desc) rowNumber from MemorialHall mh inner join Member m on mh.MemberID=m.MemberID where mh.IsStop=0‘+@condition+‘) t where rowNumber between ‘+CONVERT(varchar(100),@BeginIndex) +‘ and ‘+CONVERT(varchar(100),@EndIndex) set @sqlCount=‘select @RecordCount=count(*) from MemorialHall mh inner join Member m on mh.MemberID=m.MemberID where mh.IsStop=0‘+@condition set @sql=@sqlCount+@sql print @sql exec sp_executesql @sql,N‘@RecordCount int output‘,@RecordCount output END
时间: 2024-10-06 08:40:13