日期:2014-05-17 浏览次数:20781 次
exec sp_executesql N'
SELECT * FROM (
SELECT ROW_NUMBER() OVER (ORDER BY @strOrder) AS pos,@strGetFields
FROM [MemberAlbum] @strWhere) AS sp
WHERE pos BETWEEN (@PageIndex-1)*@PageSize+1) AND @PageIndex*@PageSize',
N'@strWhere varchar(250),@strOrder varchar(250),@strGetFields varchar(250), @PageIndex int,@PageSize int',
@strWhere='WHERE ID>10',@strOrder='EditTime DESC',@strGetFields='*',@PageIndex=1,@PageSize=20
declare @tsql varchar(6000),@strWhere varchar(250),@strOrder varchar(250),@strGetFields varchar(250),@PageIndex int,@PageSize int
select @strWhere='WHERE ID>10',
@strOrder='EditTime DESC',
@strGetFields='*',
@PageIndex=1,
@PageSize=20
select @tsql='SELECT * FROM '
+' (SELECT ROW_NUMBER() OVER (ORDER BY '+@strOrder+') AS pos,'+@strGetFields
+' FROM [MemberAlbum] '
+ @strWhere+') AS sp '
+'WHERE pos BETWEEN '+rtrim((@PageIndex-1)*@PageSize+1)
+' AND '+rtrim(@PageIndex*@PageSize)
exec(@tsql)