为和总是提示变量没定义?
Declare @Month int
declare @MonthStr nvarchar(30)
set @Month=9
if @Month>9
set @MonthStr=Str(@Month,2)
else
set @MonthStr=Str(@Month,1)
declare @UserBillTbl nvarchar(50)
set @UserBillTbl='Userbill'+@MonthStr
exec ('select * from '+@UserBillTbl+' where telno=''83561000''')
declare @dbTable nvarchar(20)
set @dbTable='db'+@MonthStr
declare @SihuaFeeSum int
declare @TmpStr nvarchar(500)
Set @TmpStr='select @SihuaFeeSum=sum(total) from '+@dbTable+' where extension>=83561000 and extension<83562000 and (ChargeID=10 or ChargeID=11 or ChargeID=12) '
print @TmpStr;
exec (@TmpStr)
运行后给出@SihuaFeeSum没定义,请大侠们指点