22,206
社区成员
发帖
与我相关
我的任务
分享
if @strSql=''
with table_temp as (select row_number() over(order by @strId) as rowIndex,* from Orders)
select * from table_temp where rowIndex between @startIndex and @endIndex
else
begin
set @strSql='
with table_temp as (select row_number() over(order by '''
+ @strId +
''') as rowIndex,* from Orders)
select * from table_temp where rowIndex between '
+ LTRIM(@startIndex) +
' and '
+ LTRIM(@endIndex) +
' and ' + @strSql
exec(@strSql)
end