Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 Stored procedure gives time out from .NET

Author  Topic 

VijayDebnath
Starting Member

1 Post

Posted - 2009-10-12 : 12:00:16
I am executing a Stored Procedure from .NET which gives timeout error and my command timeout is 60 seconds.

Same stored procedure when executed from SQL Management studio returns result in 6 seconds.

I am unable to understand why this ia happening.

I have tried with both ExecuteReader and ExecuteDataset .NET method,
but same result.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-10-12 : 12:34:30
Compare the execution plans for when it runs from SSMS and also when it runs from the .NET app. You can view the execution plans in SQL Profiler by adding the Showplan XML.

I have a feeling that the execution plans are vastly different. Let us know what you find and we can help resolve it.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

tbean
Starting Member

1 Post

Posted - 2009-10-14 : 16:30:05
Tara,

We recently installed a new server running SQL Server 2008 and have had a time-out problem with a stored procedure, executed from a .NET appliation. The stored procedure executed fine on SQL Server 2005 running on a server with fewer processors and less memory.

I don't know how moving to SQL Server 2008 would have affected the stored procedure. Your comment about execution plans being different made me wonder if recompiling the stored procedure would solve the problem so I ran sp_recompile against it. The next time the .NET application ran the stored procedure, it executed successfully.

Would you recommend running sp_recompile for all the stored procedures in our databases?

Thanks,
Tom
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-10-14 : 16:52:08
If you have a slower period or a maintenance window, then yes. You may also want to consider running update stats with fullscan (recommended after upgrades).

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -