Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 SSIS:columns to rows, load into another table

Author  Topic 

natew010
Starting Member

1 Post

Posted - 2011-09-20 : 09:04:22
Hey guys, I was hoping you all could help me out with this. So I have a table in my database with columns and a value for each of those columns tied to a specific partnumber. The other table also contains the partnumber and two other columns named "attribute name" and "value". What I need to do is take those columns (width, thickness, etc) and their values from table A, and turn them into rows in the other table (now the column name from table A will be the value under "attribute name" and the value from table A will be in the column "value". Here is an example of what table B currently looks like:

PartNumber AttributeName Value

T573 Metal Type 5
T573 Product Line 3
T573 Styling 7
R422 Metal Type 9
R422 Product Line 2
R422 Styling 1

So after the package runs, it should look like:

PartNumber AttributeName Value

T573 Metal Type 5
T573 Product Line 3
T573 Styling 7
T573 Width 2.14
T573 Thickness 3

etc...

I need to do this for each unique partnumber.

Can you guys help me with the SQL statement to do this and the SSIS job?

Thanks a lot!!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-20 : 11:18:04
why do you need ssis for this? isnt it matter of sql script like

INSERT INTO DestinationTable
SELECT PartNumber,AttributeName,AttributeValue
FROM SourceTable
UNPIVOT (AttributeValue FOR AttributeName IN ([width],[thickness],...))u


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -