• You can use Output clause for that task.

    Actually it is one of the features I love in t-sql

    Please check for examples at T-SQL OUTPUT Clause Sample and T-SQL OUTPUT Clause in order to INSERT Data in Two Tables in One Command

    Please also check the below code

    /*

    CREATE TABLE IDTable1 (

    Id int identity(1,1),

    username varchar(10)

    )

    GO

    CREATE TABLE IDLogTable (

    IDLogTable_Id int identity(1,1),

    IDTable1_Id int

    )

    */

    insert into IDTable1

    output inserted.id into IDLogTable(IDTable1_Id)

    values ('eralper')

    I hope that helps,