all groups > sql server programming > october 2006 >
You're in the

sql server programming

group:

Left processes after killing thread that executed stored procedure



Left processes after killing thread that executed stored procedure Alexander Korol
10/19/2006 11:48:01 PM
sql server programming: Hello!

I am using SQL Server 2005. VB.NET framework2

I have to execute long running code in SQL Server. The execution is started
in a separate thread in my application. What I need - is to stop execution
whenever a certain event occures and start calling same long running
procedure with other parameters. The problem is I can not just let first
procedure work till its end. The operations it does require lot of CPU time.
So I really need to interrup the previous execution first. I tried to kill
the thread in my application calling Thread.Abort - it really does what is
needed - execution of procedure stops. CPU becomes low. In VB code I close
connection. But if I look Activity monitor - There is Process that has status
runnable and some locks. And there are as many such processes as many there
were threads killed. So the connection does not seem to be closed or ...?

Any ideas of how to solve my problem or at least how to leave the process in
Status 'sleeping' are greately appreciated.

Re: Left processes after killing thread that executed stored procedure Roger Wolter[MSFT]
10/20/2006 12:41:26 PM
Depending on what software you use to connect to the database, there should
be a cancel command method or function:

http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.cancel.aspx

This may or may not work depending on what the database is doing, it may not
be listening for commands from the client.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Alexander Korol" <AlexanderKorol@discussions.microsoft.com> wrote in
message news:DA1D009C-DC57-4E70-9318-8B2E507E8778@microsoft.com...
[quoted text, click to view]

Re: Left processes after killing thread that executed stored proce Alexander Korol
10/20/2006 1:05:02 PM
Thanks a lot Roger! That really helped.

Why haven't I found that myself :))

[quoted text, click to view]
AddThis Social Bookmark Button