views:

42

answers:

2

Consider a stored procedure that updates some rows about in 60 seconds without using a transaction. We set ADO.NET's SqlCommand.Timeout to 30 seconds.

SqlCommand.Timeout = 30;

When that timeout occurs at 30 seconds, will the stored procedure continue to run in database server or not? How does the server communicate this to the client?

A: 

If you haven't closed your SQL connection yet, it should continue to run if it started proc execution already. (You should be able to test & verify this relatively easily.)

Cahit
+2  A: 

The answer is no, your attempted action on the server will fail after 30s, your SqlCommand object will throw an exception in your code (below) and the implicit stored procedure transaction will rollback.

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

...at least this is the behavior that I can verify using SQL Server...

Tahbaza
Ther special here is "implicit transaction". ALL sql commands, at least each one alone, are AUTOAMTICALLY part of an IMPLICIT transaction, even if no transaction is set explicitly.
TomTom