How to kill a long running business process

If you ever have a business process that’s been running for an extended period of time it’s more than likely going to be because of something going on in the database. One instance that I had come up lately was a dynamic selection being dumped into a temp table. This was part of an out of box acknowledgement process and instead of running for 5 seconds it was running for 12 hours.

Open SSMS and connect to the SQL server instance that you are wanting to kill the process on. Run the below script on the database.

select * from sys.dm_exec_requests cross apply sys.dm_exec_sql_text(sql_handle)

You should get data that is similar to what is below.

Now look in CRM and look at the date started for the process, that’s what you want to use to look in the data above to find the session_id. Be sure to remember what time zone your servers are in.

Now if you look for that date started in the SQL data you will see what session_id needs to be killed. So now run the script below to kill the session.

kill [session_id]

Now if you refresh CRM you will see that the process has been killed.

Please be advised that this can cause potential data integrity issues, so be aware of what code is actually being executed. At the time I wasn’t able to reset IIS and after doing some research the code that was being executed was just an insert into a temp table.

Happy coding!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s