Getting the inserted identity is quite easy in SQL. All you have to do is the following:
SELECT IDENT_CURRENT('MyTable')