Have two tables
Table VendorMaster
|VendorID|Vendor|
| 1 |Vendor1|
| 2 |Vendor2|
Table Data
|DataID|VendorID|ProductName|Quantity|
| 1 | 1 | Product1 | 100 |
| 2 | 1 | Product2 | 200 |
| 3 | 2 | Product1 | 400 |
| 4 | 2 | Product2 | 100 |
A vendor can have multiple products which are referred using foreign key Now I have another table used for staging the data
Table Staging
|StagingID|Vendor|ProductName|Quantity|
I need to insert or update the data into the Data table and Vendor table from the Staging table. Like the staging table can be used to update only the quantities or add new vendor and / or product.
How do I proceed with it? I am using SQL Server.
I tried using this, but it cannot update / insert the foreign key master table.