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.
| Author |
Topic |
|
fralo
Posting Yak Master
161 Posts |
Posted - 2010-03-10 : 11:37:33
|
| I need this ASAP. I need to update 'windowsusername' field in table A with what is in the 'username' field in Table B. The link between the two tables is email field.Thanks for your help. |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2010-03-10 : 11:41:55
|
| update aset windowusername = b.usernamefrom TableA ainner join TableB bon a.email = b.email=======================================There are no passengers on spaceship earth. We are all crew. -Marshall McLuhan, educator and philosopher (1911-1980) |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-03-10 : 11:44:23
|
"I need this ASAP"Then pay a consultant instead of relying on people's free time here!UPDATE ASET A.windowsusername = B.usernameFROM TableA AS A JOIN TableB AS B ON B.email = A.emailWHERE COALESCE(A.windowsusername, '') <> COALESCE(B.username, '') |
 |
|
|
fralo
Posting Yak Master
161 Posts |
Posted - 2010-03-10 : 11:53:14
|
| Sorry! Didn't mean to sound harsh. I should have worded it differently.Thanks for your help. |
 |
|
|
fralo
Posting Yak Master
161 Posts |
Posted - 2010-03-10 : 12:32:41
|
| When I use this it updates everything to the same value!update aset windowusername = b.usernamefrom TableA ainner joinTableB bon a.email = b.emailI thought this would fix it. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-10 : 12:42:38
|
quote: Originally posted by fralo When I use this it updates everything to the same value!update aset windowusername = b.usernamefrom TableA ainner joinTableB bon a.email = b.emailI thought this would fix it.
then it may be that you've same value for all rows of table b------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
fralo
Posting Yak Master
161 Posts |
Posted - 2010-03-10 : 13:22:26
|
| When I execute it, I receive an error:"The multi-part identifier 'USERS_1.WindowsUserName could not be found."It is changing the name of my table from USERS to USERS_1 for some strange reason. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-03-10 : 13:45:56
|
| Suggest you post the EXACT query you are using pls. |
 |
|
|
|
|
|