运用存储过程可以对数据进行分页,这样提起出的数据也能快速在页面上绑定显示:
create procedure getDate
( @size int,--页面条数大小 @currentPage--当前的页数 )
as
declare @strsql varchar(500)--要执行的SQL语句
declare @newtable varchar(30)--虚拟表名称变量
declare @start int--起始点
declare @end int--结束点
set @newtable='#s'
set @start=(@currentPage-1)*@size+1
set @end=@currentPage*@size
set @strsql='select identity(int ,1,1) as rowindex,test.* into '+@newtable+' from test' set @strsql=@strsql+' select * from '+@newtable+' where rowindex between '+cast(@start as varchar(2))+' and '+cast(@end as varchar(2))+' drop table '+@newtable exec(@strsql)
以上内容参考了http://www.cnblogs.com/freeliver54/archive/2006/12/31/608858.html