简单问题,菜鸟不懂,高手指点,弄不懂不睡觉!!!!

JadyWang 2003-10-19 11:50:01
CREATE procedure dbo.jady_Pagination
@TableName varchar(20),
@IndexCol char(20),
@CurrentPage int,
@PageCount int,

@EndBool bit output

as

declare @LastRecord int


set @LastRecord=(select top 100 IndexCol from QQ_Person_Online where IndexCol=@CurrentPage*@PageCount order by IndexCol)


exec('select * from ' + @TableName + ' where '+@IndexCol+' between ((' + @CurrentPage + '-1)*' + @PageCount + '+1) and ' + @CurrentPage + '*' + @PageCount + ' order by '+@IndexCol)

if(@LastRecord=2)
begin
set @EndBool=1
end
else
begin
set @EndBool=0
end
GO
问题在set @LastRecord…………一句
其中的IndexCol(列名),QQ_Person_Onilne(表名)该如何参数化?为什么@CurrentPage和@PageCount可以直接用变量代入而@IndexCol和@TableName却不可以?
请祥解,谢谢!
...全文
45 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
arrow_gx 2003-10-20
  • 打赏
  • 举报
回复
用动态SQL实现

set @sql=............................

exec(@sql)
txlicenhe 2003-10-20
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2364/2364046.xml?temp=.829693
[交流]动态SQL语句

22,207

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧