I have this query but updates the whole region_tmp table, which I dont want to, I only need to update a row in region table if anything has changed. I know I can specify which row with the regionid but am looking for something more general since I have a lot of records.
UPDATE REGION_TMP t SET
REGIONID=R.REGIONID,
REGIONDESCRIPTION=R.REGIONDESCRIPTION
FROM REGION R
WHERE R.REGIONID = T.REGIONID;
REGION TABLE:
| REGIONID | REGIONDESCRIPTION |
|---|---|
| 1 | AMERICA |
| 2 | EUROPE |
| 3 | ASIA |
REGION_TMP TABLE:
| REGIONID | REGIONDESCRIPTION |
|---|---|
| 1 | AMERICA |
| 2 | EUROPE |
| 3 | AFRICA |
My desire output in REGION_TMP:
| REGIONID | REGIONDESCRIPTION |
|---|---|
| 1 | AMERICA |
| 2 | EUROPE |
| 3 | ASIA |