November 12, 2003 at 3:35 pm
I want to merge data from one table to another(if unique key found then update, else insert). These tables reside on different databases on the same SQL Server. Can some suggest the best way of doing this. Using a stored procedure or DTS or any other idea.
November 13, 2003 at 6:05 am
I do this sort of thing frequently and use SP to do it. First I update first table by inner join second table on key. Then I left outer join the tables again and insert missing rows (key is null). I do it in this sequence so that I do not have the overhead of updating inserted rows.
Edited by - davidburrows on 11/13/2003 06:05:56 AM
Far away is close at hand in the images of elsewhere.
Anon.
November 13, 2003 at 11:43 am
Very similar to David's suggestion:
1. Put the data in a temporary table. 2. Join the tables and update the matching records in the destination table. 3. Join the tables again, this time deleting the matching records from the temporary table. 4. Insert any records left in the temp table to the destination table.
JM
November 14, 2003 at 12:15 pm
Thanks guys!!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply