Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Stop Sql 2008 Stored Proc from Client

Author  Topic 

tchinedu
Yak Posting Veteran

71 Posts

Posted - 2011-08-25 : 00:55:24
What is the best way to stop a stored procedure execution from client.

1. Can I use the ADO Command object's timeout for stored procs.
2. Can I just close the sqlConnection from the client and it'll stop the stored procedure execution

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-25 : 02:04:50
is it direct stored proc call or are you calling it through a sql job?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

tchinedu
Yak Posting Veteran

71 Posts

Posted - 2011-08-25 : 04:04:10
Its a direct Stored proc call as in

SqlCommand.BeginExecuteReader...with an async call back handler to end the call

The primary stored procedure sometimes calls other stored procedures, functions and SSRS etc.

Just wondering if Closing the connection will stop the stored procedures and all other procedures or functions it might have spawned.


SqlCommand command = null;
SqlConnection connection = new SqlConnection(GetConnectionString());

command = new SqlCommand(commandText, connection);
connection.Open

AsyncCallback callback = new AsyncCallback(HandleCallback);

command.BeginExecuteNonQuery(callback, command);

...
...
connection.Close or connection.Dispose()
Go to Top of Page
   

- Advertisement -