For a t-sql solution you can use UNPIVOT to transform columns to rows:declare @t table (id int, nm varchar(10), typ varchar(10), color varchar(10), qty int, txt varchar(10))insert @tselect 1, 'name1', 'type1', 'color1', 10, 'note1' union allselect 2, 'name2', 'type2', 'color2', 20, 'note2' select up.id ,up.col as sourcecolumn ,up.val as [value]from ( select id, nm,typ,color,convert(varchar(10), qty) qty,txt from @t --YOUR TABLE ) dunpivot (val for col in ([nm], [typ], [color],[qty],[txt])) upOUTPUT:id sourceColumn value----------- ---------- ----------1 nm ame11 typ type11 color color11 qty 101 txt note12 nm name22 typ type22 color color22 qty 202 txt note2
Be One with the OptimizerTG