Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Compare 2 tables and copy missing records

$
0
0

I am pretty much a SQL novice as I don't use it often except for a few simple queries. I am trying to figure out how I can compare 2 tables to see if any record is missing and copy the missing record.

So example is:

table1

item#, item name, characteristic, id

1, apple, red, 1

1, apple, crispy, 2

1, apple, sweet, 3

2, orange, orange, 4

2, orange, sour, 5

3, grapes, green, 6

3, grapes, sweet, 7

3, grapes, seedless, 8

4, kiwi, green, 9

table2

1, apple, red, 1

1, apple, sweet, 2

2, orange, orange, 3

2, orange, sour, 4

3, grapes, green, 5

3, grapes, sweet, 6

What I need happen is to update table2 to:

1, apple, red, 1

1, apple, sweet, 2

2, orange, orange, 3

2, orange, sour, 4

3, grapes, green, 5

3, grapes, sweet, 6

1, apple, crispy, 7

3, grapes, seedless, 8

4, kiwi, green, 9

Thanks in advance for any assistance.

Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>