USE [ch06] GO /****** 对象: StoredProcedure [dbo].[p_Transfer] 脚本日期: 09/24/2009 11:26:46 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER procedure [dbo].[p_Transfer]( @money int ) as BEGIN TRY begin tran t1; -- insert into t_Account(aa)values('dsdds'); update t_Account set balance = balance -@money where id = 1; update t_Account set balance = balance + @money where id = 2; commit tran t1; END TRY BEGIN CATCH rollback; SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_MESSAGE() AS ErrorMessage; END CATCH;