sql 存储过程分页(2)
@KeyField varchar(500)
)
AS
Begin
Declare @SqlTable AS varchar(1000)
Declare @SqlText AS Varchar(1000)
Set @SqlTable='Select Top '+CAST(@PageNumber*@PageSize AS varchar(30))+' '+@QuerySql
Set @SqlText='Select Top '+Cast(@PageSize AS varchar(30))+' * From '
+'('+@SqlTable+') As TembTbA '
+'Where '+@KeyField+' Not In (Select Top '+CAST((@PageNumber-1)*@PageSize AS varchar(30))+' '+@KeyField+' From '
+'('+@SqlTable+') AS TempTbB)'
Exec(@SqlText)
End
GO
内容版权声明:除非注明,否则皆为本站原创文章。