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 2008 Forums
 Transact-SQL (2008)
 Copy a field from table

Author  Topic 

Steve2106
Posting Yak Master

183 Posts

Posted - 2015-02-02 : 09:15:58
Hi There,

About a month ago I was asked to make every users email in a user table to be just one email address.
I made a backup of the table before the change.
Now I need to put the users email address back to what it was.

How would I use an update and set based on the UserId in both tables.

Thanks for your help.

Best Regards,


Always Learning.

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-02-02 : 09:40:25
[code]
update usertable
set emailaddress = othertable.emailaddress
from usertable
join othertable
on usertable.userid = othertable.userid
[/code]
Go to Top of Page
   

- Advertisement -