Help on Sql query
I ahve table 1 data , How can i populate table2 data?
In table 1 and table 2 id column in unique identifier.
table 1
id code col1 col2 col3
12345 xyz eng ger frenc
table2
id table1_id col1
5673 12345 eng
5364 12345 ger
5242 12345 frenc
Plz help me
June 16th, 2011 2:21pm
This is the so called transpose load, basically you span a row into columns.
I done it may be once or twice using a Script Component. I assume the Table2.id is auto-generated.
But Unpivot Transformation must be a better approach, see
http://blogs.msdn.com/b/philoj/archive/2007/11/10/transposing-rows-and-columns-in-sql-server-integration-services.aspxArthur My Blog
Free Windows Admin Tool Kit Click here and download it now
June 16th, 2011 2:44pm
Hi Daniel
You can unpivot the table1 using sql query
Insert into table_2
(
table1id,
col1
)
select ID,coli
from (select ID,col1,col2,col3 from table_1)p
unpivot
(coli for col in(col1,col2,col3))
as unpvt
June 17th, 2011 1:56am
Hi Daniel
You can unpivot the table1 using sql query
Insert into table_2
(
table1id,
col1
)
select ID,coli
from (select ID,col1,col2,col3 from table_1)p
unpivot
(coli for col in(col1,col2,col3))
as unpvt
Free Windows Admin Tool Kit Click here and download it now
June 17th, 2011 2:00am