在一个表中插入数据时,在第二个表中填充自动数据 [英] Fill automatic data in second table when insert data in one table

查看:77
本文介绍了在一个表中插入数据时,在第二个表中填充自动数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表Table1和Table2,在Table1中我有2列Table1_Id(主键)和Name,在表2中我有3列Table2_Id(主键),Table1_Id和Status(true和False).....当我将数据插入Table2时,我希望自动传输Table2中table1中的数据,其状态为False ....

是否可能......如果是,那么?

I have two table Table1 and Table2, in Table1 i have 2 column Table1_Id(Primary Key) and Name and in Table2 i have 3 column Table2_Id(Primary Key),Table1_Id and Status(true and False)..... when i insert data into Table2 that time i want automatic transfer that data in table1 from Table2 which have Status False....
Is it possible ... if yes than how?
Please

推荐答案

有几种方法可以做到这一点。使用触发器 [ ^ ]将是一种常见方法。

这是一个After Insert触发器的示例 - SQL Server:编码后插入在SQL Server中触发 [ ^ ]。
There could be several ways to do this. Using triggers[^] would be a common approach.
Here is an example of an After Insert trigger - SQL Server: Coding the After Insert Trigger in SQL Server[^].


这篇关于在一个表中插入数据时,在第二个表中填充自动数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆