Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Speed in Store procedure and Query Analyser
Message
From
29/05/2001 08:10:19
 
 
To
28/05/2001 19:52:36
Larry Santos
Local Data System
Philippines
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00511319
Message ID:
00512142
Views:
12
I don't have a firm answer. I'd wouldn't be surprised if the stored procedure
was doing a table scan due to the work that occurs in the WHERE clause
>    (CAST (CAST (t.nMONTH AS VARCHAR)
>    + '/01/' + CAST (t.nYear AS VARCHAR)
>    AS DATETIME)
>    >= CAST (CAST(@M3 AS VARCHAR)+'/01/'+CAST(@Y3 AS VARCHAR) AS DATETIME) AND
>    CAST (CAST (t.nMONTH AS VARCHAR)
>    + '/01/' + CAST (t.nYear AS VARCHAR)
>    AS DATETIME)
>    < CAST (CAST(@M4 AS VARCHAR)+'/01/'+CAST(@Y1 AS VARCHAR) AS DATETIME))  and
>	t.CDISTmgr = @cDistMgr
I wonder if the query optimizer is doing somekind of substitution on these values when the query is submitted as ad-hoc.

Does the stored procedure speed up if you create the DATETIME values outside of the query? At least two of them appear to be constant once the variables are assigned.

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Reply
Map
View

Click here to load this message in the networking platform