returnfields
end
set @sql+=' from #t
where rowid>@lastmaxid order by rowid'
set @sql+=' select @total total,'+cast(@pagesize as nvarchar)+' pagesize,'+cast(@pageindex as nvarchar)+' pageindex'
set @sql+=' if object_id(''tempdb..#t'') is not null
drop table #t'
exec(@sql)
END
?
?
效率对比
?
1. declare @pcount int,@rcount int
exec [dbo].[xp_getpager_user_dt] ?
? ? @pcount ?output, ? ?--总页数输出 ?
? ? @rcount ?output, ? ?--总记录数输出 ?
? ? @tablename ='v_pn_users_fromlocal', ? ?--查询表名 ?
? ? @keys ='code', ? ? ? ?--主键 ?
? ? @fields ='code,name,fname,email,isvalid,hiredate,hireva lid,quitdate,costcenter,sex,IDCard,PassDate', ? ?--查询字段 ?
? ? @where ='quitdate>''2015-01-01''', ? ?--查询条件 ?
? ? @sortfields ='quitdate', ? ?--排序字段 ?
? ? @beginindex =0, ? ? ? ?--开始位置 ?
? ? @pageindex =1, ? ? ? ?--当前页数 ?
? ? @pagesize =100
?
执行时间:1 min 18s
?
2. [xp_GetPager_user_dt2] @quitdate='2015-01-01',@pagesize=100
?
执行时间:<1s