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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stored procedured takes too long to run 1

Status
Not open for further replies.

shaminda

Programmer
Jun 9, 2000
170
US
The following stored procedure takes too long to run. How can I rewrite this procedure so it will run faster? Sometimes it times out too.

CREATE PROCEDURE [spGetQtyOrderedAS400WorkOrder]
@fdShortNumber varchar(15)
AS
Select sum(WAUORG) as TotalOrdered, sum(WASOQS) as TotalShipped
From F4801
Where WASRST < '95' AND WAITM = @fdShortNumber
GO
 
First thing first, hit CTRL +K and run it again from query analyzer
do you see any table scans?

also why this
Where WASRST < '95'
instead of
Where WASRST < 95 you might be getting a conversion which will result in an index scan instead of an index seek

Denis The SQL Menace
SQL blog:
Personal Blog:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top