Linux初探欢迎您的投稿,投放方法请点击
这里查看,我们会定期赠送精美小礼品给优秀的投稿作者。海纳百川 取则行远!LinuxGoo欢迎您的到来。
--使用说明 本代码适用于MsSql2000,对于其它数据库也可用.但没必要 --创建存储过程 CREATE PROCEDURE pagination @tblName varchar(255), -- 表名 @strGetField......
if @strWhere != '' set @strSQL = 'select top ' str(@PageSize) ' ' @strGetFields ' from ' @tblName ' where ' @fldName ' ' @strTmp ' (' @fldName_t ') from (select top ' str((@PageIndex-1)*@PageSize) ' ' @fldName ' from ' @tblName ' where ' @strWhere ' ' @strOrder ') as tblTmp) and ' @strWhere ' ' @strOrder end end exec (@strSQL) go
--测试 create table news --建表 ( n_id int iDENTITY(1,1) primary key, n_title char(200), n_content text )
--写循环插入1000000条的数据 create proc tt as declare @i int set @i=0 while(@i<1000000) begin insert into news(n_title,n_content) values('sb','dsfsdfsd') set @i=@i 1 end exec tt
exec pagination 'news','*','n_id',1000,2,0,0,''
3/3 首页 上一页 1 2 3 |