Since you have SET XACT_ABORT ON' when you do yourRAISERROR () you're setting theXACT_STATE` to -1, which means that you cannot do any transactional work in the database, you can only cancel the transaction.
An example of using temp procs and one of your triggers above:
create proc
as
begin try
begin tran
exec
commit tran
end try
begin catch
if @@trancount > 0 rollback
select error_message();
end catch
go
create proc
as
set xact_abort on;
begin try;
DISABLE TRIGGER [dbo].[trg_dml_CorrectionType_InsteadOfDelete] ON [dbo].[CorrectionType];
select xact_state() one;
raiserror('Error!', 16,1)
select xact_state() two
end try
begin catch
select xact_state() three;
select error_message() as msgprior;
ENABLE TRIGGER [dbo].[trg_dml_CorrectionType_InsteadOfDelete] ON [dbo].[CorrectionType];
select xact_state() four;
declare @error nvarchar(2500)
select @error = error_message()
raiserror(@error, 16,1);
end catch
GO
exec
You have several options, I believe:
- XAC XACT_ABORT OFF.
XACT_STATE ROLLBACK
.
- ENABLE/DISABLE
proc
.
proc; / .