我做了一個存儲過程,並得到了下面的錯誤消息,不知道爲什麼。我一直在四處尋找一些答案,並與辦公室的其他人在一起,但他們都不確定這個問題。希望這裏的某個人有同樣的問題,並且知道解決方案。子查詢不存在,存儲過程
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