–方式一
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[USP_ProcedureWithTransaction_Demo]’) and OBJECTPROPERTY(id, N’IsProcedure’) = 1)
drop procedure [dbo].[USP_ProcedureWithTransaction_Demo]
GO
— =============================================
— Author:
— Create date:
— Description:
— =============================================
Create PROCEDURE [dbo].[USP_ProcedureWithTransaction_Demo]
As
Begin
SET XACT_ABORT ON
Begin Transaction
Insert Into Lock(LockTypeID) Values(‘A’)–此语句将出错,LockTypeID为Int类型
Update Lock Set LockTypeID = 2 Where LockID = 32 本文来源gaodaimacom搞#^代%!码&网(
Commit Transaction
SET XACT_ABORT OFF
End
GO