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)
 UPDATE but not INSERT

Author  Topic 

WaterWolf
Starting Member

24 Posts

Posted - 2006-02-08 : 07:35:39
Hello,

I haven't really used DTS package much before and I'm having trouble doing what would seem like a very basic thing. This is probably a very stupid question !

Anyway, I want to copy data from certain columns in an excel spreadsheet into certain columns in a sql server table. I want to update the rows in the table that share the same key as the data being copied. If no key in the sql server table matches the data then I do not want the row to be inserted. I've tried using the import wizard but I can only seem to get it too insert new rows. Is there an easy way of doing this ?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-08 : 08:00:21
Import the data to new staging table. Compare the data with yourTable and do updation

Update Y
set col=S.col
from yourTable Y inner join StagingTable S
on Y.keycol=S.keycol

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -