You can do it in two ways
1) By select
max(id)
Select max(id) from tableName order by id DESC
2)By use of @
@@IDENTITY
After insert query you have to return
@@IDENTITY
Which returns last Inserted ID of a colimn
Insert into tableName.........
SET @id=SCOPE_IDENTITY()
select @id
You can retrive it using execute scalar, datatable or dataset, datareader as you wish
For more info.....
SCOPE_IDENTITY (Transact-SQL)[
^]
identity-and-scope_identity-in-sql-server[
^]