简体   繁体   English

MS SQL-使用触发器将数据从一个表插入到另一个表

[英]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.

相关问题 sql-从一个表中获取数据以在触发器中插入另一个表 - sql- get data from one table to insert into another in a trigger 如果满足条件,SQL 触发器将数据从一个表插入到另一个表 - SQL trigger to insert data from one table to another if a condition is met 创建SQL触发器(插入或更新),它将从一个表中获取数据并将其放置到另一个数据库表中 - Creating SQL Trigger (insert or update) which will take data from one table and will put to another database table 如何使用 SQL 中的事务将数据从一个表插入到另一个表? - How to insert data from one table to another using transactions in SQL? SQL将数据从一个表插入到另一个表 - Sql insert data from one table to another 使用SQL Server触发器将数据插入到另一个表 - Insert Data To Another Table Using SQL Server Trigger 如何使用插入查询将数据从一个 SQL 表插入另一个表 - How can I insert data from one SQL table to another table using Insert query SQL:使用一个表中的数据将新数据插入到另一个表中 - SQL: Using data from one table to insert new data into another table MS SQL将一个表中的最新三个日期插入到与一列匹配的另一个表中 - MS SQL Insert most recent three dates from one table into another table matching on one column 如何使用SQL将数据从一个表插入到另一个表 - How to insert data from one table to another with sql
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM