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
 General SQL Server Forums
 New to SQL Server Programming
 Is my query right?

Author  Topic 

sadbjp
INNER JOIN

41 Posts

Posted - 2007-05-11 : 14:38:50
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

38200 Posts

Posted - 2007-05-11 : 14:43:54
[code]
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
[/code]

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

sadbjp
INNER JOIN

41 Posts

Posted - 2007-05-11 : 14:46:55
Tara,

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

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-05-11 : 14:47:57
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

121 Posts

Posted - 2007-05-14 : 09:30:43
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
   

- Advertisement -