SQL Server: Stopping Queries Externally?

SQL Server keeps track of all executing processes. You can review the list by using stored procedures SP_WHO and SP_WHO2 each process has a unique SPID In the past, I have copied and customized the code behind these procedures for my own purposes You can check the query last executed on a SPID using DBCC INPUTBUFFER (@SPID) You can kill most processes using KILL @SPID Do note that it is not generally considered a good idea to kill processes because you may not be sure about exactly what they are doing.

SQL Server keeps track of all executing processes. You can review the list by using stored procedures SP_WHO and SP_WHO2 - each process has a unique SPID. In the past, I have copied and customized the code behind these procedures for my own purposes.

You can check the query last executed on a SPID using DBCC INPUTBUFFER (@SPID) You can kill most processes using KILL @SPID Do note that it is not generally considered a good idea to kill processes because you may not be sure about exactly what they are doing.

Ah, I see. The commands I run are ones that I run and sometimes they need to be killed and the database just emptied so its ok I guess in this case! – Abs Nov 18 '09 at 11:56.

Depends how you're calling that SQLCMD. Are you running it as a call to exec()? The PHP commands don't give you a lot of control.

If you're doing something time-consuming, it might be better to use a Producer-Consumer architecture. Have your main program publish (to a database, or a text file) the command to be run. Have a separate process (another PHP script, perhaps) run that command - but before it starts the SQLCMD, have it provide its process ID (or some other handle) to the main program.

Then, in your main program, you can kill the spawned process if it is taking too long. Some of the comments on the PHP exec function might be enlightening: au2.php.net/manual/en/function.exec.php.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions