将变量从触发器传递到存储过程 [英] Pass variables to stored procedure from trigger
本文介绍了将变量从触发器传递到存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
CREATE TRIGGER MyTrigger ON TableA
AFTER INSERT
AS
DECLARE @COLUMN1 AS NVARCHAR
DECLARE @COLUMN2 AS NVARCHAR
DECLARE @COLUMN3 AS NVARCHAR
SELECT @COLUMN1=COLUMN1,@COLUMN2=COLUMN2 FROM INSERTED
EXEC STOREDPROCEDURE @COLUMN1,@COLUMN2,@COLUMN3=?
我有两个名为表A和表B的表,并且出于插入目的,两个表都有两个存储过程.当表A的存储过程将成功执行时,将触发一个触发器来调用表B的存储过程,但是我的问题是如何将参数传递给表B的存储过程?就像我的情况一样,表A不包含column3,但是在表B中,我需要在Column3
i have two tables named table A and Table B and for the insertion purpose i have two stored procedure for both table. and when Table A''s stored procedure will executes successfully a trigger will fire to call Table B''s Stored procedure But My Question is How to pass parameter to Table B''s stored procedure? as in my case table A does not contain column3 but in Table B i need To insert data in Column3
推荐答案
中插入数据,将表B中的@ COLUMN3参数存储为可选过程.
Make @COLUMN3 parameter in Table B storedprocedure as optional parameter.
这篇关于将变量从触发器传递到存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文