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
 SQL Server Development (2000)
 Compare and update tables data

Author  Topic 

hshung
Starting Member

2 Posts

Posted - 2004-03-11 : 04:16:25
Hi

I use SQL server 2000 DTS to copy DatabaseA TableA to DatabaseB TableB every day.

Can I only copy the updated or new data from TableA to TableB ?

How to do it ?

Thanks for any help!

Hung

nr
SQLTeam MVY

12543 Posts

Posted - 2004-03-11 : 04:47:51
Easiest way is to put a timestamp on TableA, save the last value transferred and transfer data with values greater.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2004-03-11 : 15:47:20
...or if you have an identity-field you could do something like this:

INSERT INTO tableB
SELECT * FROM tableA WHERE ID >
(SELECT MAX(ID) FROM tableB)
Go to Top of Page

hshung
Starting Member

2 Posts

Posted - 2004-03-11 : 22:37:28
Thanks Lumbago & nr.

I can use :
Select * from TableA where not ID in (Select ID from TableB)
to find the new records.

But my problem is how to find the updated records in TableA ?

It is not allowed to modify TableA because it is not my DataBase.

Hung
Go to Top of Page
   

- Advertisement -