Update Data from One Database to Another with Both Tables Containing Unique References

  • Here is how I did that:

     

         UPDATE cust

         SET cust.ContactEmail = originalCust.ContactEmail

         FROM DBName1.dbo.Customer cust, DBName2.dbo.Customer originalCust

         WHERE cust.custID = originalCust.custID

     

    The statement above is written very similarly to the SELECT statement-where we join two or more tables to retrieve data.

     

    In this example:

    • Instead of SELECT, we have an update statement.
    • Instead of SELECT Columns we have SET columns that update the data automatically.

     

    Comments are welcome!

    Leave a comment