如何使用事务在具有主键和外键关系的2个表中插入值 [英] how to insert values in 2 tables with primary and foreign key relation using transaction
本文介绍了如何使用事务在具有主键和外键关系的2个表中插入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请问有人告诉我如何在单个查询中插入2个表中的值,表结构为:
飞机表
援助aname cruisingrange
和另一张桌子是
员工
援助工资
这些是两个表的字段,我想使用trransaction使用主键和外键关系在单个查询中插入两个表中的值
请一些人告诉... ...
Pls some one tell that how to insert values in 2 tables in single query, the table structure are:
Aircraft table
aid aname cruisingrange
and another table is
Employee
eid aid salary
these are the fields for both tables and i want to insert values in both tables in single query using primary and foreign key relationship using the trransaction
Pls some one tell......
推荐答案
基本上你不能在sql2005中的单个查询中更新多个表
但是,还有其他方法可以达到相同的效果 - 交易,触发器,输出......
看看这个链接的回复是否有些具体示例
http://stackoverflow.com/questions/2044467/how-to-update-two-tables-in-one-statement-in-sql-server-2005 [ ^ ]
Essentially you can't update more than one table in a single query in sql2005
However, there are other ways to achieve the same effect - transactions, triggers, OUTPUT ...
Have a look at the responses to this link for some specific examples
http://stackoverflow.com/questions/2044467/how-to-update-two-tables-in-one-statement-in-sql-server-2005[^]
这篇关于如何使用事务在具有主键和外键关系的2个表中插入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文