SQL Server 2005带事务的存储过程示例[自用标记]
set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgo-- =============================================-- Author:<Author,,Name>-- Create date: <Create Date,,>-- Description:<Description,,>-- =============================================ALTER PROCEDURE [dbo].[ssidb_DeleteDepartment]@orgID varchar(32)ASBEGINbegin tran TranStartsave tran FirstPointupdate [dbo].[ssidb_Organization]set [DelFlag]=1where [ID]=@orgIDupdate [dbo].[ssidb_Organization]set [DelFlag]=1where ID in (select a.ID from dbo.ssidb_Organization a, dbo.ssidb_f_cid(@orgID) bwhere a.ID = b.ID)if @@ERROR <> 0begin rollback tran FirstPointendcommit tran TranStartEND