简体   繁体   中英

Update column data in one table when id in other table is created

I have two tables: tblInvoice and tblAppointment I want tblInvoice to be automatically updated when a new Appointment is created (the Appointment number is created automatically) I've tried everything I've read on here and nothing works so I have to keep on deleting what's already in the Invoice table and using an Insert stored procedure to fill it up. How can I get it to update without duplicating the Appointment numbers whenever a new Appointment is created? Need code for the stored procedure and c# to put into my save button on the add Appointment page to make it work. Thanks.

Do you use a stored procedure to create the new entry in the Appointment table?

At the end of that stored procedure, you need to find the entry in the Invoice table you want to update. If such an entry exists, you want to update it. In order to find this out, there has to be some sort of relationship between your two tables. I cannot know the relationship unless you share your data model with us.

Please share your stored proc and table definitions.

创建一个触发器,该触发器将在对tblAppointment的任何插入之后更新tblInvoice

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM