- SQL code
CREATE TRIGGER [TR_UPDATACPTK001] ON ACPTKFOR UPDATE,INSERTAS DECLARE @TD001 CHAR(04), @TD002 CHAR(11), @TD003 CHAR(04), @TD005 VARCHAR(60), @TD006 VARCHAR(60), @TD008 NUMERIC(16,6), @TD010 NUMERIC(17,8), @TK017 CHAR(4), @TK018 CHAR(11) BEGIN TRANSACTION SET NOCOUNT ON SELECT @TK017=TK017,@TK018=TK018 FROM INSERTED SELECT @TD001=TD001,@TD002=TD002,@TD003=TD003,@TD005=TD005,@TD006=TD006,@TD008=TD008,@TD010=TD010 FROM PURTD WHERE [email protected] AND [email protected] UPDATE ACPTK SET [email protected],[email protected],[email protected],[email protected] WHERE @TD003='0001' AND [email protected] AND [email protected] UPDATE ACPTK SET [email protected],[email protected],[email protected],[email protected] WHERE @TD003='0002' AND [email protected] AND [email protected] SET NOCOUNT OFFCOMMIT TRANSACTION
------解决方案--------------------
不要用变量,使用inserted和要更新的表直接关联