Last post May 19, 2015 07:21 AM by gimimex
May 19, 2015 02:47 AM|mnmhemaj|LINK
I have one table like this:
I need to copy this table data to another table and the result should be like this:
May 19, 2015 02:54 AM|oned_gk|LINK
SELECT * INTO TABLE2 FROM TABLE1
INSERT INTO TABLE2 (no,val1,val2,val3) SELECT no,val1,val2,val3 FROM TABLE1
May 19, 2015 05:00 AM|mnmhemaj|LINK
Sorry for the error in my question. I've corrected it now.
May 19, 2015 07:21 AM|gimimex|LINK
Try using Unpivot:
with CTE_Unpivot as( select [No], [Val]
[Val] for ValX in ([Val1], [Val2], [Val3])
) as u)insert into Table2 select [No], [Val] from CTE_Unpivot
Hope this helps.