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 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Importing data from table to table

Author  Topic 

jblanton
Starting Member

3 Posts

Posted - 2007-05-21 : 10:10:00
I need to copy data from within a table and paste it into another table. I tried overwriting the table but my dependencies/triggers get screwed up. I'm going to use an example to better clarify what I'm trying to do.


On one 2000 SQL Server I have a table with 500 phone numbers in it. Let's say I have a table in my personal 2000 SQL Server with the exact same structure, however I only have 10 phone numbers in it. I need to overwrite the data in my personal SQL server with the data from a different SQL server.

I've exported the table to my personal SQL server now. They both reside in 1 database. How can I copy the data from the newly copied table to my existing table (which has the same structure, both tables were automatically created with Pharos Uniprint 7.2)?

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-05-21 : 10:40:19
Try this:

insert into target_table select * from source_table ...
Go to Top of Page

jblanton
Starting Member

3 Posts

Posted - 2007-05-22 : 10:11:25
That didn't seem to work. I need to copy the data from one table to another. The data needs to be overwritten, but the table can't be deleted. I've tried transforming (deleting its contents via the transformation GUI)the table while exporting directly to the other table but my values get sorted differently and they aren't recognized. Any other ideas?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-22 : 10:13:56
do a delete first before inserting

delete target_table
insert into target_table ( . . . )
select . . .
from source_table



KH

Go to Top of Page
   

- Advertisement -