alter PROCEDURE [dbo].[up_custompage]
@order_column_name varchar(100),
@select_column_list varchar(3000),
@select_table_list varchar(1000),
@condition varchar(8000),
@page_size int,
@current_page int,
@total1 int output
AS
declare @temp1 varchar(3000),@temp2 nvarchar(3000),@page_total int,@last_page int
set @temp2=N'select @total2=count(*) from ' + @select_table_list + ' where ' + @condition
--print @temp2
exec sp_executesql @temp2,N' @total2 int output ',@total1 output
if @total1>0
begin
set @temp1= 'select Row,' + @select_column_list + ' from(select Row_Number() over (order by ' + @order_column_name +
') as Row,' + @select_column_list + ' from ' + @select_table_list + ')as Temp where Row>=' + cast(@page_size*(@current_page-1)+1 as varchar(10)) +
' and Row<=' + cast(@page_size*@current_page as varchar(10))
print @temp1
exec(@temp1)
select @total1 as totoal,@@RowCount
end
else return
通用分页存储过程
最新推荐文章于 2011-03-31 09:46:00 发布