Information générale
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
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement