473,473 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 7254
(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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.