Avatar of yadavdep
yadavdep
Flag for India asked on

Long running Stored Procedure in SQL Server 2012

We have a stored procedure that takes around 40 to 60 seconds sometimes to finish.

As it depends on customer data.

Now the issue is when users start this SP from a web form, sometimes the users get timeout error from SQL Server or Asp.net Ajax as well.


Now we don't want to increase the time-out limit.


Is there something like some background process or task which we can run on the SQL server and show the users processing and timely check whether that task is finished or not?


Is there anything like this in SQL Server?



* SQL Server 2012 EnterpriseASP.NETMicrosoft SQL Server

Avatar of undefined
Last Comment
Jim Horn

8/22/2022 - Mon
David Johnson, CD

what are the long running processes in the execution plan of the stored procedure
yadavdep

ASKER
David,

This SP has more than 100 lines to execute, so there is no one specific thing that is taking time.
It keeps changes user by user
Andrei Fomitchev

You can schedule a SQL Agent Job to execute SP and store result in an intermediate table.
Your web app will select result from the intermediate table with zero waiting time.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
Jim Horn

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question