SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 explanation of sql
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Auris
Starting Member

United Kingdom
7 Posts

Posted - 05/23/2012 :  06:52:35  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Germany
8529 Posts

Posted - 05/23/2012 :  09:35:07  Show Profile  Visit webfred's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000