SQL Server: Kill process running xp_cmdshell
Posted by Prashant on August 6, 2010
In our last post we discussed how to run a VB Script from SQL Server. Here I will share something interesting related to that task. Well, while extending the program logic of my VB Script I have used some message boxes to check the flow of some variable values. I also ran that script from command line, that finished successfully.
Now, when I try it to run my TSQL code (which uses xp_cmdshell to run that script) and observed that it is taking an unexpected time to complete !!! After sometime I think of killing the process and killed, but still the query was running where I got a Success message from KILL !!!
Here is the reason behind that…after testing my script I forgot to remove/comment the message boxes, which cause my TSQL to run for an indefinite time.
Solution:
- The script or application we are calling from TSQL (xp_cmdshell) should be self-sufficient, i.e. application should not have any user interaction like InputBox or MessageBox, Visual Windows…etc.
- To stop the query which call such applications, we need to end the process from windows Task Manager.
Note: xp_cmdshell always run the target application in background and user can’t end it interactively to regain the control from that application.
More information for this topic is available here on Microsoft Support site or refer Book Online. Hope this helps you.
Share this:
Like this:
This entry was posted on August 6, 2010 at 1:15 PM and is filed under Kill Process, Operating System, SQL Server. Tagged: kill-xp_cmdshell, Prashant Pattnaik, SQL Journey, SQL Server, xp_cmdshell. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


