Monday, June 25, 2012

Joining String


DECLARE @categories varchar(1000)
SET @categories = NULL
SELECT @categories = COALESCE(@categories + ',','') + CONVERT(VARCHAR(20),WIndApplicationID) FROM dbo.WIndApplications
WHERE WIndFormTypeID = 4

PRINT @categories


SELECT ',' + CONVERT(VARCHAR(20),WIndApplicationID)
FROM dbo.WIndApplications
WHERE WIndFormTypeID = 4
FOR XML PATH('')