我做了一个存储过程,并得到了下面的错误消息,不知道为什么。我一直在四处寻找一些答案,并与办公室的其他人在一起,但他们都不确定这个问题。希望这里的某个人有同样的问题,并且知道解决方案。子查询不存在,存储过程
Msg 116, Level 16, State 1, Procedure Name_Stored_Procedure,
Line 113 Only one expression can be specified in the select list
when the subquery is not introduced with EXISTS.
这里是我的代码
Set @SQLstring =
'Update #TempTable set Col1' + case when len(Convert(Varchar, ([email protected])))=1
then '0' else '' end
+ Convert(Varchar,([email protected])) + '=''' +
(select @Year, @Month,
Convert(Varchar,count(distinct Table.Column1))
from Databse.Table
where DATEPART(yy,Time) = @Year
and DATEPART(mm,Time) = @Month
and Table.Column2 = @Column2 and Column3 in ('X','Z','Y - A'))
+''' where row = ' + CONVERT(varchar,[email protected] * 12)
exec('' + @SQLstring +'')
谢谢,对不起,它被视为一个字符串。我只是忘了在描述中输入它。尽管如此,仍然有相同的问题。 干杯 – SterlinkArcher
@andrejcurcic请参阅编辑。 – podiluska