ASP.NET分页组装HTML代码
// ASP.NET分页组装HTML代码 //by bruce at 2017-05-15 17:31:41 // public class Pager { public Pager(string _CateName, int _PageIndex, int _Total, int _PageSize) { this.PageIndex = _PageIndex; this.Total = _Total; this.PageSize = _PageSize; this.CateName = _CateName; } public int PageIndex { get; set; } public int Total { get; set; } public int PageSize { get; set; } ...
sql server使用ROW_NUMBER分页
ALTER PROC usp_GetPageList ( @tableName VARCHAR(20) , @selectColunms VARCHAR(1000) , @sortColumn VARCHAR(50) , @sortType VARCHAR(4) , @pageIndex INT , @pageSize INT ) AS BEGIN DECLARE @sql NVARCHAR(4000) SET @sql = ' SELECT * FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY '+ @sortColumn +' '+ @sortType +' ) AS orderIndex , ' + @selectColunms + ' FROM ' + @...
ROW_NUMBER分页
--提取分页数据,返回总记录数 create procedure Proc_GetDataPaging_ReturnDataCount ( @SqlString varchar(6000), --查询语句 @PageNumber int, --当前的页码 @PageSize int, --每页显示的数据量 @SequenceField varchar(100), --排序字段 @DataCount int out --总数据量 ) as begin --提取总记录数 declare @Sql nvarchar(2000) set @Sql = N'select @countNum = count(1) from ('+ @SqlString+') as a' exec sp_executesql @Sql,N'@countNum int out',@DataCount out declare @BNum int declare ...
SQL各种分页方法汇总
SQL各种分页方法汇总 平常工作,尤其是面试中经常遇到这样一个问题,查询表A中31到40条的记录,ID可能是不连续的。 如果ID连续 select * from A where ID between 31 and 40 如果ID不连续,提供三种写法 --两次对表A查询效率较低 select top 10 * from A where ID not in (select top 30 ID from A) --外层查询没有对表A查询,效率大有提高 select top 10 * from (select top 40 * from A order by ID) as t order by t.ID desc --ROW_NUMBER()函数效率更高,s...