SQL Server分布式事务模板
USE [task]
GO
/*==========================================================
Server: test
DataBase: task
Author: aaa
SPName: UP_UPdateData
Version: 1.0
Date: 2009-11-15
Content: UP_UPdateData
* Parameters
* --------------------------------------------------------
* Input :
*
* Output : N/A
*
*
* Table Used :
* ---------------------------------------------------------
* dbo.tblTask
-----------------------------------------------------------
Modified history:
Date Modified by VER Description
------------------------------------------------------------
2009/11/15 XXX 1.00
==========================================================*/
CREATE PROCEDURE dbo.UP_UPdateData
(
@TaskID INT
)
AS
BEGIN
SET NOCOUNT ON
SET XACT_ABORT ON --使用分布式事务需要(使用连接服务器)
BEGIN TRY
BEGIN TRANSACTION
--更新链接服务器上的表数据(dbserver.dbname.dbo.Tablename)
IF (@@RowCount > 0)
BEGIN
--插入本地数据
END
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
END
GO