I got this error when I parse multiple data to sql server for a report. This error happens when I put the data line by line, if I manully separate the data by comma, it works fine. Here is my query which works fine in query designer.
DECLARE @sql varchar(1000)
BEGIN
SET @sql = 'Select pn_id,Count(pn_id)as Number
from dbo.pen_link_component
where pn_id in ('+@userid+') and invitemlk_ky= 503569
Group by pn_id'
END
EXECUTE (@sql)