[英]MS SQL - insert data from one Table into another using Trigger
I have few data's in Table_1 & want to insert the data into Table_2. 我在Table_1中的数据很少,并且想将数据插入到Table_2中。
Is it possible to perform this operation using Trigger function in MS SQL? 是否可以使用MS SQL中的Trigger函数执行此操作?
Also I want this to data to insert into table_2 automatically in a specific time. 我也希望此数据在特定时间自动插入到table_2中。
Can this be performed using SQL Trigger? 可以使用SQL触发器执行此操作吗?
New to SQL... SQL新手...
Perhaps an instead of trigger could be of use? 也许代替触发器可能有用吗?
CREATE TRIGGER [schema_name.] trigger_name
ON {table_name | view_name }
INSTEAD OF {[INSERT] [,] [UPDATE] [,] [DELETE] }
AS
{sql_statements}
Note though that you will have to insert into both tables in the trigger as you are "overriding" the standard INSERT
. 请注意,尽管您要“覆盖”标准
INSERT
但必须将其插入到触发器的两个表中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.