Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Update Table from Second Table

Update Table from Second Table

Update Table from Second Table

Forgive me if I've posted this in the wrong forum...

We have a Database 'CP' with several tables, one of which is 'Customers'. We went into the 'Customers' table and made changes to both the 'SalesRep' column and the 'Category' column. Now, 45 days later, they want the changes made to the 'SalesRep' column to be undone.

I have a backup of the table before any changes were made and I have restored it to 'CustomersOLD' and have gone in and updated the 'Category' column and left the 'SalesRep' column alone. However, the current table has had 300+ new customers added and several hundred of the rows of the existing customers have been modified. I can't simply import the new customers into the old table and replace.

I don't know if the syntax exists, can I combine the 2 tables, based on the 'CustomerNumber' column, and update the existing 'SalesRep' column with the data that is in the 'CustomersOLD' table, 'SalesRep' column?

UPDATE Customers SET 'SalesRep' = 'CustomersOLD.SalesRep' WHERE 'Customers.CustomerNumber' = 'CustomersOLD.CustomerNumber'

Since the 'CustomerNumber' is incremental, do I need to run a FOR loop?

Thanks for all of your help!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close