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
 General SQL Server Forums
 New to SQL Server Programming
 Importing split data into Table

Author  Topic 

guygamer
Starting Member

3 Posts

Posted - 2006-04-04 : 10:49:00
Hi,

I have Data split into 3 text files with 3 fields repeated in each to link then (key). I want to import this data into one table.
I used DTS to create 3 tables with the data. Now i want to combine the 3 tables into only one (that i already created). How can i do this? Note: the field names in the source tables are different from the destination table.

Thanks

Guy

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-04-04 : 10:58:34
so you want to add new rows to the table or add new columns?

Go with the flow & have fun! Else fight the flow
Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"]
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-04-04 : 11:00:06
Doesn't matter the diff in field names but the # of field names should be same.

Insert Into DestinationTbl (field1, field2 .....)
Select FieldA, FieldB,....
Union All
Select FieldP, FieldQ,....
Union All
Select FieldX, FieldY,....


Srinika
Go to Top of Page

guygamer
Starting Member

3 Posts

Posted - 2006-04-04 : 11:12:01
Hi Srinika,

Will that create one record with the 3 related records in the source files?

Guy
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-04-04 : 11:29:04
No, it will create 3 records.

I assumed all data of 3 tables should be added to one table as different records.

Can u please provide with ur table structures, sample data and desired results
[Make sure u place data or code inside code tags provided in this page]

Srinika
Go to Top of Page

guygamer
Starting Member

3 Posts

Posted - 2006-04-05 : 13:14:04
Hi,

I used your method to load the first source table in the destination table. Now i planned to use UPDATE commands to copy the values in the second and third tables. Is there a better way.

Thanks
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-04-05 : 13:21:31
May be,
but we can help you only if u provide with ur table structures, sample data and desired results
since v don't know actually what u r going to do.

Srinika
Go to Top of Page
   

- Advertisement -