create procedure pagination
(
@sql nvarchar(1024),
@pagesize int = 20, --分页大小
@pageindex int = 0, --分页索引
@sort nvarchar(100) = '''', --排序字段
@totalcount int = 0 output --总数
)
as
set nocount on
/*声明查询字符串*/
declare @strSQL nvarchar(4000)
set @strSQL = '' select @TotalCount=count(*) from () as t ''
/*取得查询结果总数*/
exec sp_executesql
@strSQL,
int=0 OUTPUT'',
@TotalCount=@TotalCount OUTPUT
declare @ItemCount int
declare @_PageIndex int
set @_PageIndex = @PageIndex + 1;
/*确定搜索边界*/
set @ItemCount = @TotalCount - @PageSize * @_PageIndex
1. 页面全部经过SEO(搜索引擎优化)处理 2. 支持IE、FireFox等主流浏览器,在IE 和FireFox下显示相同的效果 3. 符合W3C国际网页标准,页面全部采用DIV+CSS布局 4. 采用SQL server数据库,所有数据库操作采用存储过程 5. 部分功能采用AJAX技术,良好的用户体验。 6. 后台集成在线HTML编辑软件FCKEditor,自定义美观的内容
0
if(@ItemCount set @ItemCount = @ItemCount + @PageSize
else
set @ItemCount = @PageSize
if(@ItemCount
if(@Sort != '''')
begin
/*声明排序变量*/
declare @IndexSort1 nvarchar(50), @IndexSort2 nvarchar(50), @Sort1 nvarchar(50), @Sort2 nvarchar(50)
SET @Sort1 = @Sort
SET @Sort2 = Replace(Replace(Replace(@Sort, ''DESC'', ), ''ASC'', ''DESC''), , ''ASC'')
print @Sort1
print @Sort2
set @strSQL = ''SELECT * FROM
(SELECT TOP '' + STR(@ItemCount) + '' * FROM
(SELECT TOP '' + STR(@PageSize * @_PageIndex) + '' * FROM
() AS t0
ORDER BY +'') AS t1
ORDER BY +'') AS t2
ORDER BY ''
end
else
begin
set @strSQL = ''SELECT * FROM
(SELECT TOP '' + STR(@ItemCount)
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号