SELECT Col1, LEFT([Col2], LEN([Col2]) - 1) as [Col2] FROM ( SELECT DISTINCT Col1 FROM tablename ) AS A OUTER APPLY ( SELECT RTRIM(B.Col2) + ', ' FROM tablename B WHERE A.Col1 = B.Col1 FOR XML PATH('') ) AS C ([Col2])
You will have to use Pivot/UnPivot
select convert(varchar,User_id) + "," + business +"," + row3 +"," + row4
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)