• As stated before your going to use update and insert of course but look at the keyword

    EXISTS

    and the functions

    SCOPE_IDENTITY, IDENT_CURRENT, and @@IDENTITY (hint triggers and other events can affect the results of one or more of these)