Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2010
    Posts
    2

    Unanswered: Copy data from one table to another

    Client ran an update query and removed all phone numbers from the phone field of the Customers table.
    Client restored database to a new named instance.
    Client renamed Customers table in new instance to CustomersRestored.
    CustomersRestored table was copied from new instance into production database.
    Production database now has a table Customers and a table CustomersRestored.

    Desire: Copy all phone data from CustomersRestored into Customers table matching on the Customer Account Number field.

    Don't know how to write the query to make this happen. Can anyone help?
    Thanks!
    Craig.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    UPDATE Customers 
       SET Customers.phoneno = CustomersRestored.phoneno
      FROM Customers 
    INNER
      JOIN CustomersRestored
        ON CustomersRestored.AccountNumber  = Customers.AccountNumber
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2010
    Posts
    2

    Worked perfectly - Thank You!

    Worked perfectly - Thank You!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •