如何使用触发器将记录插入到多个表中? [英] How to insert a record into multiple tables using a trigger?
本文介绍了如何使用触发器将记录插入到多个表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两张桌子.
我想同时在两个表上插入相同的记录.
即,当我为第一个表插入一条记录时,同样的记录也使用触发器插入到第二个表中.
I want to insert the same record on both tables at the same time.
I.e., while I insert a record for the first table, this same record also is inserted in the second table using a trigger.
您在这个过程中有什么经验/建议吗?
Do you have any experience/advice in this process ?
推荐答案
如果您正在使用存储过程,您可以轻松管理此
if you're using stored procedures you can easily manage this
CREATE PROCEDURE sp_Insert
@Value varchar(10)
AS
insert into table1 (...,...) values (@value,...)
insert into table2 (...,...) values (@value,...)
这篇关于如何使用触发器将记录插入到多个表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文