Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update performance 1

Status
Not open for further replies.

Naith

Programmer
May 14, 2002
2,530
GB
Is there a more efficient way to perform this update?
Code:
UPDATE TSR_Forecast
SET TSR_Forecast.fc_sales_district_id = b.sales_district_id
FROM TSR_Actuals b
WHERE TSR_Forecast.customernumber = b.apple_hq_id
AND fc_sales_district_id IS NULL
and sales_district_id <> 'SP20'
At the moment, despite indices on all the fields concerned, the performance on this is incredible (in a bad way).
 
Try making it a join instead.

Code:
UPDATE tf
SET fc_sales_district_id = b.sales_district_id
FROM TSR_Forecast tf
JOIN TSR_Actuals b
on tf.CustomerNumber = b.Apple_hq_ID
WHERE tf.fc_sales_district_id IS NULL
and b.sales_district_id <> 'SP20'

I'm not sure where Sales_District_ID is coming from. You may need to change that.



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
I like the look of this. Seems to be a lot easier on the processing.

Thanks. Have a star.

-N
 
Glad I could help. @=)

Thanks for the star.



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top