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)
 explanation of sql

Author  Topic 

Auris
Starting Member

7 Posts

Posted - 2012-05-23 : 06:52:35
hi guys, i have this sql update statement written and i dont understand how it acually knows which record/s to update. Its from the production and its working correctly for 4 years, the problem is we are implementing some changes and now i need to udpate it.

UPDATE RiskSubjectivity
SET RiskId = e.RiskId
FROM RiskCorrespondence rc
JOIN Endorsement e
ON e.AppliedToRiskId = rc.RiskId
WHERE e.RiskId = @RiskId

the question is how does it determines which RiskSubjectivity row to update since no join is applied to it? i have written update and delete joins but i have never seen one like this.

explanation or an article on the topic would be good.

Thank you


Life is hard. It's even harder if you're stupid.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-05-23 : 09:35:07
What I see is: all rows will be affected but maybe there is only one row in table RiskSubjectivity...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -