I have four tables: A,B,C,D. A has PK of B, B has PK of C and C has PK of D. I want to insert data to all of them. I have tried using Output Into by using two tables
declare @a table(
no int identity(1,2),
nama varchar(30)
)
declare @b table(
no int identity(1,1),
nama varchar(40)
)
insert into @b (name) values('test')
merge @a
using @b
on 0=1
when not matched
then insert (nama)
Values ('test2')
output inserted.no, inserted.nama into @b;
select * from @b
How can I add more Output Into so I can insert PK of @b to another table?