DECLARE @M TABLE ( ParameterName NVARCHAR(20), ParameterValue NVARCHAR(MAX) ); INSERT INTO @M VALUES ('1', 'Napis1 &<'), ('1', 'Napis2 &'), ('1', 'Napis3'), ('2', 'aaa'), ('2', 'bbb'), ('3', 'a'); SELECT * FROM @M SELECT DISTINCT ParameterName, RemappedValues = STUFF( ( SELECT ';' + ParameterValue FROM @M AS M2 WHERE M2.ParameterName = M1.ParameterName FOR XML PATH(''), ROOT('ParameterString'), TYPE ).value('/ParameterString[1]', 'nvarchar(max)'), 1, 1, '' ) FROM @M AS M1;