See illustration heredeclare @t table(type varchar(30),unit int,krone int,slot int,port int)insert @tvalues('VZ2Wire', NULL, 1, NULL, 2),('DSLAMGLite', 1, NULL, 6, 2);With CTEAS(select *from @tunpivot (val for cat in (unit,krone,slot,port))u)select [DSLAMGLite],[VZ2Wire]from(select TYPE,STUFF((SELECT '/' + cat from CTE where TYPE = c1.TYPE FOR XML PATH('')),1,1,'') AS cats,1 AS ItemOrdfrom (select distinct TYPE from CTE)c1UNION ALLselect TYPE,STUFF((SELECT '-' + CAST(val as varchar(10)) from CTE where TYPE = c1.TYPE FOR XML PATH('')),1,1,'') AS vals,2from (select distinct TYPE from CTE)c1)mPIVOT (MAX(cats) FOR TYPE IN ([DSLAMGLite],[VZ2Wire]))poutput----------------------------------------DSLAMGLite VZ2Wire----------------------------------------unit/slot/port krone/port1-6-2 1-2
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs