Добрый день, всех с наступающим.
Есть примерно такой код :
+ |
while exists (select * from table0)
begin
begin try
exec dbo.proc
end try
begin catch
print error_message()
end catch
end
-----------------------------------
procedure proc
@Error_Message output
declare @sql varchar(max)
set xact_abort on
set @_sql ='update T1 from ['+SRVR+'].['+DB+'].['+SCHM+'].Table1 set F1 = 5'
begin transaction
begin try
exec(@_sql);
commit transaction;
set @Error_Message = '';
end try
begin catch
set @Error_Message = error_message();
rollback transaction;
end catch |
При выполнении строки update на удаленном сервере в триггере на таблицу Table1 вызывается Raiserror + rollback.
При выполнении в студии скрипта с циклом получаю примерно такую ошибку
Msg 1206, Level 18, State 118, Procedure Table1_Upd, Line 158
The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction.
и выполнение цикла обрывается.
А очень хочется перехватить возникшее исключение и обработать.
Уважаемые коллеги, плиз хелп
Сервера такие :
локальный
Microsoft SQL Server 2005 - 9.00.4266.00 (X64) Oct 7 2009 17:38:17 Copyright (c) 1988-2005 Microsoft Corporation Developer Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)
удалённый
Microsoft SQL Server 2005 - 9.00.4230.00 (Intel X86) Jul 30 2009 13:45:19 Copyright (c) 1988-2005 Microsoft Corporation Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)