大家来帮一下吧!晕死了!
declare @LastRecord int
/*
declare @TableName varchar(20)
declare @IndexCol char(10)
declare @CurrentPage int
declare @PageCount int
set @TableName='QQ_Person_Online'
set @IndexCol='IndexCol'
set @CurrentPage=1
set @PageCount=2
exec('set @LastRecord=(select top 100 '+@IndexCol+' from '+@TableName+' where '+@IndexCol+'='+@CurrentPage+'*'+@PageCount+' order by '+@IndexCol+')')
*/
/*
set @LastRecord=(select top 100 IndexCol from QQ_Person_Online where IndexCol=1*2 order by IndexCol)
*/
select @LastRecord
问题如下:
若执行第一部分注释中的句子,则报错:”服务器: 消息 137,级别 15,状态 1,行 1
必须声明变量 '@LastRecord'。
(所影响的行数为 1 行)
“
若执行第二部分注释中的句子则正确,百思不得解?!