情帮忙看下事务语法对错。
[code=SQL][/code]USE [HXTst]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[Pro_AdvBackAmount]
as
BEGIN
declare @sql nvarchar(max)
declare @PeriNm int
declare @CtNm VARCHAR(MAX)
declare @OverDueCg float
BEGIN TRANSACTION
set @sql='update AdvBackInf Set ApporveState=''已审核'' where ContractNm=@CtNm'
exec @sql
set @sql='update InterestReceive set RepayAmount=receivableAmount,PeriodRepyDate=@PeriNm where ContractNm=@CtNm'
exec @sql
set @sql='update InterestReceive set RepayAmount=RepayAmount''+@OverDueCgwhere''where
ContractNm=@CtNm and PeriodRepyDate=@PeriNm and RepayType=''PeriodOverdueCharge'''
exec @sql
COMMIT TRANSACTION
IF ( @@ERROR <> 0 )
ROLLBACK TRANSACTION
end
以前都是ADO处理事务
以上代码是我的T-SQL事务处理,不知道对没有,情大家帮忙看下,
------解决方案--------------------
一个事务中有三条exec @sql,出错回滚执行只会回滚出错的操作,出错之前的操作不会被回滚的