In MS SQL I am doing this - I think it's working correctly but want to check.
UPDATE BillingInvoice
SET CustomerId = Customer.CustomerId
FROM Customer
WHERE BillingInvoice.CustomerId = Customer.CustomerNum
AND BillingInvoice.CreatedBy = 222
This is a migration from an old database, what we are doing is first dumping the old customer number into CustomerId
, then joining the Customer table, and getting the PK of the customer table, then finally putting back that PK into CustomerId
. It does seem to work but want to check that SQL is processing this correctly.