In following query I am trying to grab list of parties but it throws an error that 'Incorrect Syntax near A32'. It seems fine but not sure where I am doing wrong.
DECLARE @SQL nvarchar(4000) SET @SQL = 'DECLARE @BL nvarchar(500); SELECT @BL = COALESCE(@BL + '', '', '''') + Buyer FROM ( SELECT new_lastname, CASE new_deceased WHEN 0 THEN COALESCE(new_name, '''') + '' '' + COALESCE(new_middlename, '''') + '' '' + COALESCE(new_lastname, '''') WHEN 1 THEN COALESCE(new_name, '''') + '' '' + COALESCE(new_middlename, '''') + '' '' + COALESCE(new_lastname, '''') + '' (D)'' END AS Buyer FROM FilteredNew_party WHERE new_partytype = 1 and (FilteredNew_party.new_order = A37C6131-2A32-E611-80EA-0050568E5BEC) ) T ORDER BY new_lastname; SELECT @BL as BuyerList' EXEC (@SQL)
Any Idea?
*This post is locked for comments