Thursday, March 22, 2012

A Clarification required on xp_terminate_process

HI ,

I have a problem where i have to kill a windows process in my procedure. In sql server 2000 i could find a procedure called xp_terminate_process ( which takes process id as parmeter and kills the process) . but i couldnt find any replacement or another new one to do the same in sql server 2005. if any body have any idea or suggestion regarding how to go about this are welcome..

Thanks in advance

Mohan

I just can't imagine task required Windows process killing on database server. Could you please tell us?|||

it will be some thing like ,

i have created a package and scheduled it to run , then when it executes it will create a dtshost.exe process.i ll capturing this process id and store it . and i have some data where i can know if any job exceeds its time of excution (for eg: schduled for 10 minutes but running for 20 minutes). we can do this scheduling by using sqlserver agent. but i ll be using some other mechanism where i can control the concurrency of executions. there i ll have procedure whihch will run periodically and checks that if any job is timedout , then get the process id of that job and kill the process.

This is what my requirement is ...

thanks and Regards

Krishna Kishore

|||Maybe it would be enough just to kill sql server connection made by dtshost.exe ( using simple KILL command ) ?|||

i dont think there will be n number of connections to the n number of servers in my package ,i can not determine which connection i need to terminate. so i think kill is not sifficient. by using xp_terminate_process you can kill the entire process...

but it s not available in the sql server 2005 ? what should i do any alternate for this...

Thanks in advance

krishna Kishore

|||

Hi Krishna,

Have u used xp_terminate_procces in SQL Server 2000?, as i m using it but it doesnt seems to terminate the process, not even showing any error. I m using the following query:

exec master..xp_terminate_process <pid>

When i execute, it just says the command completed successfully....

but the process is no killed :(

Plz reply me, if u have any idea whats wrong with the query or if i m not using it correctly..

Thanks and Regards,

|||

Hi ,

you have not given your requirement clearly? But i XP_terminate_process can kill any kind of process, have you checked whether your are referring to correct pid or not?

if you still feel it's not working use xp_cmdshell to kill the proces by using a command argument

the command is taskkill

taskkill /f /pid 1234 where pid is 1234

Thanks

Krishna

|||

I m using xp_terminate_process with a correct processid, but the command is not terminating the process.(I know that its an undocumented procedure, so its not guaranteed to work). I just wanted to know if u have used xp_terminate_process successfully?

I have sqlserver 2000 with sp4. I m using the following statement.

exec master..xp_terminate_process 3254

(Here 3254 is the process id for cmd.exe, i wish to terminate)

I know about cmdshell and kill/taskkill but i dont want to use cmdshell for some reason.

Thanks for ur reply.

No comments:

Post a Comment