Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Update two fields with single value?

Author  Topic 

Lord Dubu
Starting Member

12 Posts

Posted - 2004-05-24 : 08:35:33
I've got a rather time consuming task of having to manually insert several like fields into a table I inherited from a previous programmer.

Unfortunately the individual who designed this table had an annoying habit of naming the same data in two different tables by completely different names.

So in order to update a user's ID in both tables that contain that data, I've been using two update statements:

update table set userID=NEW_userID where userID=OLD_userID
update table2 set profileID=NEW_userID where profileID=OLD_userID

I was just wondering if there is a way to send the new_userID to both fields where I only have to type the value for new_userID and old_userID once each per query?

I apologize in advance for my wording on this question. I'm sure that if I knew the correct nomenclature I'd be able to google the answer I seek.

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2004-05-24 : 08:50:03
I would have a trigger on the primary table to update the secondary table when someone updates the userId on the primary.

This way no matter how it is updated both tables get updated.




Jim
Users <> Logic
Go to Top of Page
   

- Advertisement -