I have the following database tables
- Master Table – Contains PK Id column for a data range
- Reference Table – A staging table with the data range that has the associated code
- Target Table – Table for which the Id column is to be inserted or updated based on the master and reference table
Reference Table
Code From To
Abc45 200 400
Cde78 0 128
Fcde1 600 898
Master Table
Id From To
1 1 100
2 200 400
3 0 128
4 600 898
Target Table
Name id City Country Code
West B CC Fcde1
East V GG Cde78
North T TT Abc45
South Z YY Abc45
Thanks In Advance
Try this:
I used this question Update with inner join? as reference.