SQL Server 2005带事务的存储过程示例[自用标记]

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[ssidb_DeleteDepartment]
	@orgID varchar(32)
AS
BEGIN
	begin tran TranStart
	save tran FirstPoint
		update [dbo].[ssidb_Organization]
		set [DelFlag]=1
		where [ID]=@orgID
		
		update [dbo].[ssidb_Organization]
		set [DelFlag]=1
		where ID in (
			select a.ID from dbo.ssidb_Organization a
				, dbo.ssidb_f_cid(@orgID) b
				where a.ID = b.ID
		)

	if @@ERROR <> 0
	begin 
		rollback tran FirstPoint
	end
	commit tran TranStart
END


你可能感兴趣的:(sql,SQL Server,F#,Go)