declare @newValues table (TrainId int, Id int, Remarks varchar(32))
merge TranMaster as target
using (
select
TrainId
,4
,Remarks
from TranDetails
) as source(TrainId, Id, Remarks)
On (0=1)
WHEN NOT MATCHED THEN
insert (Id)
values (source.Id)
output inserted.TrainId, source.Id, source.Remarks
into @newValues;
insert into TranDetails
select * from @newValues
|