Click here to Skip to main content
13,003,589 members (61,276 online)
Rate this:
Please Sign up or sign in to vote.
I have a Stored Procedure with CURSOR which takes around 3 minutes to run. It works fine in the Management Studio, but not in my Application.I have increased its command timeout to 600. Now, Sometimes I gets full results into the Application(When I am executing the procedure 4 or 5 times)

Can any one help me to retrieve full result on first time execution itself....

Now I removed all cursors from the query and reduced the execution time to "20 secs or less ". But Still the problem exists. The result is not complete, many rows are removed from my result.(I gets only 11965 records)
Posted 20-Dec-11 20:04pm
Updated 1-Jan-12 20:53pm
Al Moje 21-Dec-11 2:07am
Did you increased also your connection timeout?... If not then do it...
thatraja 21-Dec-11 3:28am
Show the SQL script
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


See this link if could help...
How set CommandTimeout and ConnectionTimeout

Rate this: bad
Please Sign up or sign in to vote.

Solution 3

The problem may be insufficient indexing, possibly locking issues, badly formed SQL etc.

Try to use SSMS Activity monitor to see that no locks interfere:[^]

And optimize the query and/or the underlying tables/indexes. Without seeing the statements, there's not much to help with concerning the optimization.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4


if your cursor is Forward_Only(least restrictive) then you need to check something else. please let us know what you have written in your cursor,

Please check Cursor Type

and check which type of cursor is best suite in your logic.

hope using proper type you can solve your problem


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170626.1 | Last Updated 5 Feb 2016
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100