日期:2014-05-17 浏览次数:20427 次
create proc p_page
@tablename varchar(50),
@field varchar(2000),
@order varchar(200),
@page varchar(10),--每页多少条
@pagenum varchar(10) --页码
as
begin
declare @sql varchar(5000)
set @sql='select '+@field+' from (select '+@field+',row_number() over(order by '+ @order+')/'+@page+' as page from '+@tablename+') as A where page='+@pagenum
exec(@sql)
end
declare @sql1 varchar(8000)
set @sql1='select (row_number() over(order by '+排序字段+'))/'+分页数+ ' as 分页'
+字段+' from '+表名+' order by '+排序字段
exec(@sql1)
alter proc p_page
@tablename varchar(50),
@field varchar(2000),
@order varchar(200),
@page varchar(10),--每页多少条
@pagenum varchar(10) --页码
as
begin
declare @sql varchar(5000)
set @sql='select '+@field+' from (select '+@field+',row_number() over(order by '+ @order+')/('+@page+'+1)+1 as page from '+@tablename+') as A where page='+@pagenum
exec(@sql)
end