473,587 Members | 2,229 Online
Bytes | Software Development & Data Engineering Community
+ 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 7270
(co**********@g ooglemail.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.Canc el method.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.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...@g ooglemail.com"
<codefragm...@g ooglemail.comwr ote:
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**********@g ooglemail.comwr ote in message
news:85******** *************** ***********@v16 g2000prc.google groups.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
22116
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 application server can talk to the database. I've determined the failure occurs when the the following statement is executed: cstmt.execute(); (due...
0
4373
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 some inserts will fail due to missing information or that a record already exists for it. One of the main reasons for me using the cursor is so that...
6
2720
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 DEFINE_COMMAND(CdboMyAccessor, _T("{ CALL dbo.MyProc; 1(?,?) }")) It all works sweet as, but it can take a while and I want to let the user abort it....
4
3179
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 Throwable as an OUT parameter and what datatype should I use in the CREATE PROCEDURE and DROP PROCEDURE statements? Here's what I tried: - the method...
8
7916
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 created a temporary database with a tables space. Verified that DECLARE GLOBAL TEMPORARY TABLE TEMP (A INTEGER); INSERT INTO SESSION.TEMP VALUES(10);...
2
5448
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
7
3441
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 'UpdateRegistrant' expects parameter '@EMail', which was not supplied. The field value was null in the database and not changed in the FormView so is...
7
6797
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 period of time. I want something like thread.abort for aborting aynchronous call. Can someone tell me way of aborting asynchronous call.
2
4093
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
7843
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8205
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7967
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6619
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5712
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2347
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 we have to send another system
1
1452
muto222
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.