SQL Merge Multiple Rows Into Single String (3)

Sample data

DECLARE @SampleTable AS TABLE (SampleData VARCHAR(255))INSERT INTO @SampleTable ( SampleData )SELECT 'Value 1' UNION ALLSELECT 'Value 2' UNION ALLSELECT 'Value 3'SELECT SampleData FROM @SampleTable

In the above example, FOR XML clause is used to concatenate row values. Since a comma is used, the query concatenates values separated by comma.

Resource SQL Server curry

Leave a Reply

Your email address will not be published. Required fields are marked *