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
commit transaction
set xact_abort off
end
go
