My normal process for inserting into one table and then getting the ID back so that I can insert into another table is like this in MSSQL:
DECLARE @transacti
As per the answer of @aaron-greenlee, The result variable of INSERT queries contains a key-value pair that is the automatically generated ID of the inserted row; this is available only for databases that support this feature.
And the below is possible way to return the inserted record for all databases.
INSERT INTO myTable (
title
)
OUTPUT INSERTED.*
VALUES (
)
You will get the inserted record details in result.
Hope this helps. Thanks.