Take the 2-minute tour ×

Sometimes, my web application is throwing timeout exceptions when trying to execute a specific stored procedure. From that moment on, the stored procedure will never execute again until I reboot the database server.

The strange thing is that I can execute the stored procedure manually from within the SQL Server Management studio, and the execution time is correct (about 0.2 seconds).

But if the same exact call is made from the webserver... Timeout. How is that possible?

I am using SQL Server 2012 and I'm mapping the stored procedure in my code using Linq2Sql.

Additional information: I have tried running the "detect blocking" sql from this blog post: http://blog.sqlauthority.com/2010/10/06/sql-server-quickest-way-to-identify-blocking-query-and-resolution-dirty-solution/ but no rows are returned.

share|improve this question
Are there any other specific conditions when it happens? For example, maybe it only happens when debugging? –  Alex Filipovici Jan 14 '13 at 9:41
No, it happens also when no process is attached to the debugger. I am running IIS on my machine (Windows 7). –  Andrea Jan 14 '13 at 9:44
Are you using transactions? –  Alex Filipovici Jan 14 '13 at 9:48
Not on any of the tables interested by the query that blocks.. And by the way, if transactions were the problem, shouldn't I be unable to execute the query also from the management studio? –  Andrea Jan 14 '13 at 9:49
Can you post the SP definition? And maybe the way you are using it with the LINQ to SQL? –  Alex Filipovici Jan 14 '13 at 9:52
show 1 more comment

1 Answer

up vote 1 down vote accepted

Possibly a bad query plan is cached in SQL server. You could try to recompile the Stored Procedure with the Recompile option. With this option the SP is not cached and is recompiled every time it is called.

share|improve this answer
add comment

Your Answer


