Stored Procedures takes long time to execute from Web Application
Hi,
We have a got unique problem with one of our Stored Procedure. This stored procedure takes a long time to execute when called from data access layer which is in C#, takes around 5 minutes but takes very less time to execute when executed from query analyzer, takes around 6 seconds. We are using data access block of Enterprise Library 2. All the other stored procedure within the application works fine. It is only this one stored procedure which is behaving very odd. The same stored procedure works fine if we give a short date range (6 months) from the data access layer but takes lot of time to execute when you give a bigger date range (4 years). Also doesn't seem to be a data load or network issue the reason being the 4 years date range query returns only 12 records. I have checked through the profiler it is actually the execution of the query which is taking time but the same query works fine when run through query analyzer. I have used same parameters format used by the C# layer in the query analyzer to execute the query.
Does anyone have any idea on this? Any ray of light will do. Also Is anyone aware how does the execution of SP differs when called from C# that from query analyzer, I assume both of them use the same engine and mechanism. Any inputs on this will also be very helpful.
Thanks in Advance for your help.
Many Thanks.
Kind Regards,
Sharad.

