|
The variable is not processed well
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) This will cause an error |
|