with A as(select distinct p1 from tableA)select p1,(select '%'+name from tableA where p1=A.p1 for XML path(''))+'%' from A