|
发表于 2020-2-24 14:30:01
|
显示全部楼层
是变量没有处理好
declare @sqlcommand varchar(200),@tablename varchar(100),@TotalID int,@ManagerID int
set @tablename='ta'
select @sqlcommand='select '+rtrim(@TableName)+'.AssessID,'+rtrim(@TableName)+'.RealPoint,'+rtrim(@TableName)+'.assessAccord,'+rtrim(@TableName)+'.ItemComment,AssessItem.ItemName,manager.ManagerName,TotalAssess.CheckComment,TotalAssess.StartTime,TotalAssess.EndTime,TotalAssess.NowTime
from manager,TotalAssess,AssessItem,'+rtrim(@TableName)+' where TotalAssess.TotalID='+rtrim(@TotalID)+' and TotalAssess.TotalID=Assess.TotalID and Assess.ManagerID='+rtrim(@ManagerID)+' and Assess.ManagerID=manager.ManagerID and Assess.ItemID=AssessItem.ItemID'
EXEC(@sqlcommand)这样就会出错 |
|