×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-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!
  • Students Click Here

*Eng-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

Jobs

Problem duplicating/updating table records

Problem duplicating/updating table records

Problem duplicating/updating table records

(OP)
Hello, I have the following problem:

1. I have a MS SQL 2000 database with a table of user accounts called tbl_User.

2. A faulty script was run on the data in the table and, it deleted each user's first and last name.

3. I was able to reconstruct the data and have created another table called tbl_UserFixed with the correct data.

4. Being new to SQL, I tried to delete all of the records in tbl_User and insert the correct records from tbl_UserFixed. However, this failed due to the table having constraints/dependencies.

5. My next idea was to rename tbl_User to tbl_UserOld and then rename tbl_UserFixed to tbl_User. However, when I did this in a test database, I noticed that the dependencies were not inherited.

6. I've tried using DTS, but I was unsuccessful.

7. What is the simplest way to accomplish this task? I need to fix this ASAP!

Thank you in advance.

RE: Problem duplicating/updating table records

You can do an Update query from tbl_UserFixed to the tbl_User. Check your field names!

UPDATE tbl_User INNER JOIN tbl_UserFixed
ON tbl_User.ID = tbl_UserFixed.ID
SET tbl_User.FirstName = tbl_UserFixed.FirstName

Repeat for LastName. Make sure your data is backed up before running ANY exciting queries!

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting

UK steam enthusiasts: www.essexsteam.co.uk

RE: Problem duplicating/updating table records

(OP)
Johnwm,

Thank you, your example code worked just fine! I am new to SQL, so I knew that it could be done with an update statement, and there it is! I have definitely learned my lesson this time, I will make a duplicate database and test my custom scripts on there first! Thanks again.

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 Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

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

Click Here to join Eng-Tips and talk with other members!


Resources