存储过程的代码如下所示:
CREATE PROCEDURE [dbo].[H986SyncData]
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
BEGIN TRANSACTION
BEGIN TRY
UPDATE [192.111.112.1].DATABASENAME.DBO.TABLENAME
SET
FIELD1 = 'TEST'
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK TRANSACTION;
END CATCH;
IF @@TRANCOUNT > 0
COMMIT TRANSACTION H986SyncData_TR
END
执行该存储过程时,sql server 2005报“Cannot start more transactions on this session”的错误。解决该错误的方法是在BEGIN TRANSACTION前,增加“SET XACT_ABORT ON”。