标签:des style color ar 使用 sp 数据 on bs
-- 使用方法:在获取查询列表的存储过程中执行,并指定参数就行了
-- exec ListPage @SQL, @PageSize, @PageNo, @OrderStr, @OrderType
-- @SQL 查询语句
-- @PageSize 数据数量
-- @PageNo 当前页码
-- @OrderStr 排序字段
-- @OrderType 排序 0 ASC 1 DESC
USE [DataBaseName]--数据库名称
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE ListPage
@InSQL varchar(max),
@RowNum int,
@PageNo int,
@IndexWord varchar(200),
@Order bit=0
AS
DECLARE @SQL varchar(max)
DECLARE @OrderMode varchar(10)
DECLARE @BeginRow int
DECLARE @EndRow int
BEGIN
IF @Order = 0
BEGIN
SET @OrderMode = ‘ASC‘
END
ELSE
BEGIN
SET @OrderMode = ‘DESC‘
END
IF @PageNo = 1
BEGIN
SET @BeginRow = 1
SET @EndRow = @RowNum
END
ELSE
BEGIN
SET @BeginRow = (@RowNum * (@PageNo-1))+1
SET @EndRow = @BeginRow + @RowNum - 1
END
SET @sql = ‘SELECT *,ROW_NUMBER() OVER(ORDER BY ‘+ @IndexWord +‘ ‘+ @OrderMode +‘) AS ROWNUMBER FROM (‘+ @InSQL +‘) AS A‘
SET @sql = ‘select * from (‘+ @sql +‘) as b where b.ROWNUMBER BETWEEN ‘+ convert(varchar(10),@BeginRow) +‘ AND ‘+ convert(varchar(10),@EndRow) +‘‘
Exec (@sql)
END
GO
标签:des style color ar 使用 sp 数据 on bs
原文地址:http://www.cnblogs.com/snear110-/p/4094520.html