How to Get the last identity value used
the last identity value used in an insert can be retrieved with the @@identity function.