简体   繁体   中英

Long-running stored procedure out of IIS process

I have a long running stored procedure that imports lots of records from an old system and takes hours to execute. While executing maybe the IIS process needs recycling or web server needs restart or something else that caused the IIS process to end and accordingly aborted the execution of the stored procedure.

I've decided to run the stored procedure out of w3wp.exe process, in a disconnected environment.

Solutions:

  • Service Broker Activation:I read this but it's complex and diagnosting service queue is difficult
  • Run under a Windows Service:
  • Define a SQL Server Job: it needs SQLAgentReaderRole role permission and I need pass parameters to the stored procedures

Is there any other solution?

I personally prefer the Windows Service route. Lately I've used self-hosted WebApi which allows me to start a long running job from MVC (using HttpClient or System.Net.HttpWebRequest, etc).

CLR Assembly.

change your code as a class library, and import dll result of class library as an assembly function of SSMS, with this Code

CREATE ASSEMBLY myAssembly from 'E:\Projects\CL.dll'

now you can call it without any concern of IIS stop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM