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 2012 Forums
 Transact-SQL (2012)
 Update query joining a table not working

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2014-12-30 : 09:44:49
I am trying to use the below update query, but gettign error saying Sql command not properly ended.

Also the join producing multiple rows, how to handle it. i want to upate the top one straight. not sure how to use ranking.

Update AT_Metrics_SECURITY
Set EMAIL_ADDRESS = T2.EMAIL
from AT_Metrics_SECURITY T1
Join ST_ZZ_WEB_USER T2 on(T2.USER_ID = T1.USER_ID)
where T1.Email_address is null;


Thanks a lot for the helpful info.


gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-12-30 : 09:48:02
try:


Update T1
Set EMAIL_ADDRESS = T2.EMAIL
from AT_Metrics_SECURITY T1
Join ST_ZZ_WEB_USER T2 on(T2.USER_ID = T1.USER_ID)
where T1.Email_address is null;
Go to Top of Page
   

- Advertisement -