I have table A and table B with many-to-many relationship. Table AB is a linking table.
Table: Columns:
A { Id, Name }
AB { A_Id, B_Id }
B { Id, Name }
I want to insert row into table A and then use that row's Id (Id has autoincremented identity) to insert into linking table.
Is it possible to do it in single SQL command?
Example (pseudo-sql):
insert into A (Name) values (@name)
insert into AB (A_Id, B_Id) values ([previous id], @b_Id)