you just need this and no cursorSELECT STUFF((SELECT DISTINCT ',' + CAST(A.TW_PSuid AS varchar(25)) FROM RespParty A INNER JOIN Citations B ON B.TW_PSUID = A.TW_PSUID WHERE RPName Like '%meyers%' And A.TW_PSuid Is Not Null And EntityNumber In ('0717','0718') FOR XML PATH('')),1,1,'')
If you really want to use cursor solution you need to initialise @output to '' or modify code as below... SET @output = COALESCE(@output,'') + @string + ',';..
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/