Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Is my query right?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sadbjp
INNER JOIN

41 Posts

Posted - 05/11/2007 :  14:38:50  Show Profile  Reply with Quote
Can we have a query like this:

UPDATE RubricReportDetail
SET RubricReportDetail.LocalPerf = SPPIndicatorDetails.Pct
WHERE (RubricReportDetail.IndicatorID = RubricReportTemplate.IndicatorID) AND
(RubricReportTemplate.IndicatorNumber = SppIndicator.Number) AND
(SppIndicator.SppIndicatorID = SPPIndicatorDetails.SppIndicatorID) AND
(SPPIndicatorDetails.FYY = @DataYears) AND
(SppTarget.IndicatorNumber = SppIndicator.Number) AND
(SppTarget.Years = @DataYears) AND
(SppTarget.Part = RubricReportTemplate.Part)

tkizer
Almighty SQL Goddess

USA
38200 Posts

Posted - 05/11/2007 :  14:43:54  Show Profile  Visit tkizer's Homepage  Reply with Quote

UPDATE rrd
SET LocalPerf = sid.Pct
FROM RubricReportDetail rrd
INNER JOIN RubricReportTemplate rrt
ON rrd.IndicatorID = rrt.IndicatorID
INNER JOIN SppIndicator si
ON rrt.IndicatorNumber = si.Number
INNER JOIN SPPIndicatorDetails sid
ON si.SppIndicatorID = sid.SppIndicatorID
INNER JOIN SppTarget st
ON st.IndicatorNumber = si.Number AND st.Part = rrt.Part
WHERE 
	sid.FYY = @DataYears AND
	st.Years = @DataYears


Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sadbjp
INNER JOIN

41 Posts

Posted - 05/11/2007 :  14:46:55  Show Profile  Reply with Quote
Tara,

Thanks once again. What if I use my query, will it be right?
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
38200 Posts

Posted - 05/11/2007 :  14:47:57  Show Profile  Visit tkizer's Homepage  Reply with Quote
Did you try it? Does it update the correct data? Does it give syntax errors?

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Vijaykumar_Patil
Posting Yak Master

India
121 Posts

Posted - 05/14/2007 :  09:30:43  Show Profile  Visit Vijaykumar_Patil's Homepage  Click to see Vijaykumar_Patil's MSN Messenger address  Reply with Quote
Your Query is wrong. Neither it has a sub query nor it is a join.

Necessity is the mother of all inventions!
Go to Top of Page
  Previous Topic Topic Next 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.06 seconds. Powered By: Snitz Forums 2000