alter procedure sp_aspnetpage
@curpage int
@tablename varchar()输入参数
@count int output输出参数
@order varchar()
@key varchar()
@pagesize int=
@condition varchar()==
as
begin
set nocount on
设置开始行号
declare @start_row_num int
set @start_row_num=(@curpage)*@pagesize
设置动态sql语句
declare @sql varchar()
set @sql=select top +cast(@pagesize as varchar())+* from +@tablename+ where +@condition+ and +@key+ not in (select top +convert(varchar()@start_row_num)+ +@key+ from +@tablename+ where +@condition+ order by +@order+) order by +@order
获得总记录数
declare @countnum nvarchar()
set @countnum=select @all=count() from +@tablename
exec sp_executesql @countnumN@all int output@count output
执行分页sql
print @sql
exec (@sql)
end