How can I get the last or next Identity of a table?
Returns the last identity value inserted into an identity column in the same scope. A scope is a module: a stored procedure, trigger, function, or batch. Therefore, two statements are in the same scope if they are in the same stored procedure, function, or batch.
Some more information in this question - How Do You Tell What Next Identity Column Will Be?
And this one - SQL Identity (autonumber) is Incremented Even with a Transaction Rollback
You can also query the table's current IDENTITY in Management Studio by using:
DBCC CHECKIDENT('YourTable')
but that doesn't tell you anything reliably about what the next IDENTITY will be - do not attempt to calculate the next IDENTITY yourself! Let SQL Server handle that and grab it using SCOPE_IDENTITY()
once the insert has happened - only that is relevant, really.