This question is an attempt to explore the semantics involved in the interaction between TransactionScope and xact_abort in SQL Server 2000.
If the following sql is executed within a TransactionScope, and the first delete command errors, will the second delete command be run? (Assume a foreign key from parent to child in order to ensure failure.)
create procedure test
@id int
as
set xact_abort on
-- no explicit transaction is created
-- if this fails
delete from dbo.[parentTable]
where id = @id
-- will this run?
delete from dbo.[childTable]
where id = @id
Assuming trivial application code as below:
public bool TryTestStoredProcedure()
{
try
{
using (TransactionScope t = new TransactionScope())
{
MethodThatRunsTestStoredProcedure();
t.Complete();
return true;
}
}
catch
{
return false;
}
}
What will be the return value from this method if the first delete statement in the stored procedure fails? What about if the second delete statement fails?