I've made a stored procedure and got the error message below, dont know why. I've been looking around for some answers and with some other guys here at the office but they're all unsure of the problem. Hoping someone here has had the same problem and knows the solution to this.
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.
Here is my Code
Set @SQLstring =
'Update #TempTable set Col1' + case when len(Convert(Varchar, (4+@counter)))=1
then '0' else '' end
+ Convert(Varchar,(4+@counter)) + '=''' +
(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,10+@somevariable * 12)
exec('' + @SQLstring +'')