I'm not sure if I understand the situation correctly, but why do you have two output clauses? For example the following works fine
insert into build_master(lastUpdatedOn)
output inserted.buildId,
'a',
1,
'a',
getdate(),
getdate(),
getdate(),
getdate(),
'a',
'a',
'a',
'a',
'a',
'a',
'a'
into build_versions(
buildId,
versionName,
devrecordId,
developedBy,
reportDate,
scheduledDate,
implementationdate,
closeDate,
environment,
status,
knownIssue,
comments,
functionAdded,
functionUpdated,
defectsFixed)
values(getdate());
[ADDED]
It may be hard to get values from both tables in a single run. Could you use two runs in the same batch. Consider the following
declare @MasterOutput TABLE (
buildId bigint
);
declare @VersionsOutput TABLE (
buildId bigint,
buildversionid bigint
);
insert into build_master(lastUpdatedOn)
output inserted.buildId
into @MasterOutput
values (getdate());
insert into build_versions (
buildId,
versionName,
devrecordId,
developedBy,
reportDate,
scheduledDate,
implementationdate,
closeDate,
environment,
status,
knownIssue,
comments,
functionAdded,
functionUpdated,
defectsFixed)
output inserted.buildId,inserted.buildVersionId
into @VersionsOutput
select a.buildId,
'a',
1,
'a',
getdate(),
getdate(),
getdate(),
getdate(),
'a',
'a',
'a',
'a',
'a',
'a',
'a'
from @MasterOutput a;
select * from @MasterOutput;
select * from @VersionsOutput;
The output is
buildId
-------
7
buildId buildversionid
------- --------------
7 4
Of course you wouldn't need the last two select statements since they are only for checking the result from the batch.