SyntaxFix
Write A Post
Hire A Developer
Questions
You need a table variable and it can be this simple.
declare @ID table (ID int) insert into MyTable2(ID) output inserted.ID into @ID values (1)