SQL server concatenate
DECLARE @test TABLE (
FirstName varchar(50)
)
--
INSERT INTO @test
SELECT 'Jon'
UNION SELECT 'Tom'
UNION SELECT 'Mike'
--
SELECT STUFF((
SELECT DISTINCT ', ' + FirstName
FROM @test
FOR XML PATH('')
), 1, 2, '')
DECLARE @test TABLE (
FirstName varchar(50)
)
--
INSERT INTO @test
SELECT 'Jon'
UNION SELECT 'Tom'
UNION SELECT 'Mike'
--
SELECT STUFF((
SELECT DISTINCT ', ' + FirstName
FROM @test
FOR XML PATH('')
), 1, 2, '')
Comments
Post a Comment