SQL Server: Is it possible to insert into two tables at the same time?

后端 未结 11 1369
青春惊慌失措
青春惊慌失措 2020-11-22 16:22

My database contains three tables called Object_Table, Data_Table and Link_Table. The link table just contains two columns, the identi

11条回答
  •  醉梦人生
    2020-11-22 16:41

    It sounds like the Link table captures the many:many relationship between the Object table and Data table.

    My suggestion is to use a stored procedure to manage the transactions. When you want to insert to the Object or Data table perform your inserts, get the new IDs and insert them to the Link table.

    This allows all of your logic to remain encapsulated in one easy to call sproc.

提交回复
热议问题