如何在具有一对多关系的两个表中插入数据 [英] How to insert data in two table having one to many relationship
本文介绍了如何在具有一对多关系的两个表中插入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要表格,例如
Product{Id int(PK),Name varchar(50),InvoiceId int as Foreign key}
和另一个表
Invoice{Id int(PK) ,Date date}
如果发票有多个项目,那么我如何通过存储过程插入值以保持数据一致性。如果我添加发票,则必须添加所有产品,否则必须回滚事务。谢谢
If invoice have more than one item then how can I insert values through Stored Procedure so that data consistency maintained. if I add invoice then all product must be added otherwise transaction must be rollback. Thanks
推荐答案
how-to-insert-data-to-multiple-tables-having-relationships [ ^ ]
通过它并尝试..
how-to-insert-data-to-multiple-tables-having-relationships[^]
Go through it and try..
这篇关于如何在具有一对多关系的两个表中插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文