troubleshooting Question

Make more performing the query.

Avatar of SALA DONATELLA
SALA DONATELLA asked on
Microsoft SQL ServerSQL
3 Comments1 Solution55 ViewsLast Modified:
Hello expert.
There is a way to speed up the following stored procedure:

ALTER PROCEDURE [dbo].[UpdateSalesOrderDetailFields]

AS
BEGIN
UPDATE    CurrentSalesOrderTemp
SET           AD_Mode = vBM_BillOptionHeader.OptionDesc1
FROM        CurrentSalesOrderTemp INNER JOIN
                  vSO_SalesOrderHistoryDetail ON CurrentSalesOrderTemp.SONo = vSO_SalesOrderHistoryDetail.SalesOrderNo INNER JOIN
                  vBM_BillOptionHeader ON vSO_SalesOrderHistoryDetail.BillOption2 = vBM_BillOptionHeader.BillOption
WHERE     (vBM_BillOptionHeader.BillOptionCategory = '2')

UPDATE    CurrentSalesOrderTemp
SET           TempUnits = vBM_BillOptionHeader.OptionDesc1
FROM        CurrentSalesOrderTemp INNER JOIN
                  vSO_SalesOrderHistoryDetail ON CurrentSalesOrderTemp.SONo = vSO_SalesOrderHistoryDetail.SalesOrderNo INNER JOIN
                  vBM_BillOptionHeader ON vSO_SalesOrderHistoryDetail.BillOption2 = vBM_BillOptionHeader.BillOption
WHERE     (vBM_BillOptionHeader.BillOptionCategory = '1')

UPDATE    CurrentSalesOrderTemp
SET           FiberCableCode = vBM_BillOptionHeader.UDF_CODE
FROM        CurrentSalesOrderTemp INNER JOIN
                  vSO_SalesOrderHistoryDetail ON CurrentSalesOrderTemp.SONo = vSO_SalesOrderHistoryDetail.SalesOrderNo INNER JOIN
                  vBM_BillOptionHeader ON vSO_SalesOrderHistoryDetail.BillOption2 = vBM_BillOptionHeader.BillOption
WHERE     (vBM_BillOptionHeader.BillOptionCategory = '3')

UPDATE    CurrentSalesOrderTemp
SET           FiberCableDesc = vBM_BillOptionHeader.OptionDesc1
FROM        CurrentSalesOrderTemp INNER JOIN
                  vSO_SalesOrderHistoryDetail ON CurrentSalesOrderTemp.SONo = vSO_SalesOrderHistoryDetail.SalesOrderNo INNER JOIN
                  vBM_BillOptionHeader ON vSO_SalesOrderHistoryDetail.BillOption3 = vBM_BillOptionHeader.BillOption
WHERE     (vBM_BillOptionHeader.BillOptionCategory = '3')

UPDATE    CurrentSalesOrderTemp
SET           ESPGroup = vBM_BillOptionHeader.UDF_CODE
FROM        CurrentSalesOrderTemp INNER JOIN
                  vSO_SalesOrderHistoryDetail ON CurrentSalesOrderTemp.SONo = vSO_SalesOrderHistoryDetail.SalesOrderNo INNER JOIN
                  vBM_BillOptionHeader ON vSO_SalesOrderHistoryDetail.BillOption8 = vBM_BillOptionHeader.BillOption
WHERE     (vBM_BillOptionHeader.BillOptionCategory = '8')
END

Any help will be appreciated.
Thanks in advance
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros