472,971 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,971 software developers and data experts.

Aborting a stored procedure?

Hi
Is there any way of aborting a stored procedure? I'd want to do this
from c# using async connections but if its possible from query
analyser I'd like to know.
How does the stop button work in query analyser?

thanks
Nov 3 '08 #1
5 7230
(co**********@googlemail.com) writes:
Is there any way of aborting a stored procedure? I'd want to do this
from c# using async connections but if its possible from query
analyser I'd like to know.
How does the stop button work in query analyser?
It sends an attention signal to SQL Server.

I would guess that method to use in C# is the SqlCommand.Cancel method.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Nov 3 '08 #2
which brought me to this article, thanks for the help, didn't know
that.

http://blogs.msdn.com/khen1234/archi...20/483015.aspx
Nov 5 '08 #3
On Nov 5, 2:03*am, "codefragm...@googlemail.com"
<codefragm...@googlemail.comwrote:
which brought me to this article, thanks for the help, didn't know
that.

http://blogs.msdn.com/khen1234/archi...20/483015.aspx
Bear in mind that the speed with which the DBMS responds to the
cancel signal is indeterminate. The DBMS architecture is a non-
preemptive
threading model, so for the most part, the executing thread itself
decides
when it's going to check for any external messages, such as the rare
cancel.
If it's making good progress and not needing to wait for I/O, a user
thread
may often complete before ever discovering it got a cancel signal.
Back
in my C client days I ran an experiment where I sent a long list of
individual
update statements, each inserting into a table. I sent these all in a
single
SQL string to the DBMS, and *immediately after sending the string* I
sent
a cancel. I was then able to determine how many of the rows got
inserted
before the cancel got heeded. I remember getting 472 inserts completed
out of a 500-line batch.
Joe Weinstein at Oracle
Nov 5 '08 #4
I remember getting 472 inserts completed out of a 500-line batch.
Joe Weinstein at Oracle
I gather that its, if not flaky, unpredictable in what it does. Nice
to know though.

Nov 7 '08 #5
A word of caution regarding cancelling a proc: if the proc includes an
explicit transaction, the transaction will remain open after the cancel
(unless XACT_ABORT is ON). One method to address this is to execute the
following after the cancel:

IF @@TRANCOUNT 0 ROLLBACK

--
Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/

<co**********@googlemail.comwrote in message
news:85**********************************@v16g2000 prc.googlegroups.com...
>I remember getting 472 inserts completed out of a 500-line batch.
Joe Weinstein at Oracle

I gather that its, if not flaky, unpredictable in what it does. Nice
to know though.
Nov 7 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
0
by: Jason | last post by:
I have a job created on my server which runs a stored procedure. The SP uses a cursor on a recordset to insert rows into a table (via a stored procedure - hence the cursor). It is expected that...
6
by: Mike Brown | last post by:
Hello I am calling a stored procedure in a MSDE/SQLServer DB form within my Visual C++ 6.0 program along the lines CCommand<CAccessor<CdboMyAccessor>>::Open(m_session, NULL); With...
4
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
7
by: archana | last post by:
Hi all, I am having application in which i am doing asynchronous call.I am using manualresetevent to wait for asynchronous call to complete. I want to stop asynchronous call after certain...
2
by: jed | last post by:
I have created this example in sqlexpress ALTER PROCEDURE . @annualtax FLOAT AS BEGIN SELECT begin1,end1,deductedamount,pecentageextra FROM tax
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.