Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Updating Table B from Table A SQL Server 7.0
Message
From
15/03/2002 11:32:27
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00633352
Message ID:
00633467
Views:
14
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
Map
View

Click here to load this message in the networking platform