笔记218 给定每页记录数计算一张表的总页数 @PageSize @PageIndex @TotalRecords @TableTotalPage 2012-11-22
笔记218 给定每页记录数计算一张表的总页数 @PageSize @PageIndex @TotalRecords @TableTotalPage 2012-11-22
1 --给定每页记录数计算一张表的总页数 @PageSize @PageIndex @TotalRecords @TableTotalPage 2012-11-22 2 USE [pratice] 3 DECLARE @PageIndex INT 4 DECLARE @PageSize INT 5 DECLARE @TableTotalPage INT 6 DECLARE @TotalRecords INT 7 SET @PageIndex = 1 8 SET @PageSize = 5 9 10 11 SELECT @TotalRecords = COUNT(RecordNO) 12 FROM DP_OilCanOption 13 PRINT @TotalRecords 14 IF ( @TotalRecords > 0 ) 15 BEGIN 16 IF ( @TotalRecords % @PageSize = 0 ) 17 BEGIN 18 19 SET @TableTotalPage = @TotalRecords / @PageSize 20 END 21 ELSE 22 BEGIN 23 SET @TableTotalPage = @TotalRecords / @PageSize + 1 24 END 25 END 26 PRINT @TableTotalPage