General information
Forum:
Microsoft SQL Server
Excellent
Thankyou Very much
>Assuming that the primary key of both tables is named idPrimary you can do it with two commands:
>
>DELETE FROM TableB WHERE idPrimary in (SELECT idPrimary FROM TableA)
>INSERT INTO TableB (SELECT * FROM TableA)
>
>You can also use an Update command instead of the initial DELETE command, but this becomes more complicated for three reasons: 1) Updates with JOINS can be a little complicated the first few times you use them, 2) you will need to specify field names (not a huge deal, but more typing <eg>); and 3) the Second INSERT with need a subquery.
>
>
>
>>Hello Group,
>>
>>I have fresh data in table A from remote SQL Serves. Table A has fresh data for rows in table B are already in Table B. Table A also new records for table B.
>>
>>What is the best way to update the existing records in table B and add the new records into table B.
>>
>>Thanks
>>Jim
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only