Checking for errors with @@error  Checking the transaction nesting level with @@trancount

Chapter 14: Using Batches and Control-of-Flow Language

Checking IDENTITY values with @@identity

@@identity contains the last value inserted into an IDENTITY column in the current user session. @@identity is set each time an insert, select into, or bcp attempts to insert a row into a table. The value of @@identity is not affected by the failure of an insert, select into, or bcp statement or the rollback of the transaction that contained it. @@identity retains the last value inserted into an IDENTITY column, even if the statement that inserted it fails to commit.

If a statement inserts multiple rows, @@identity reflects the IDENTITY value for the last row inserted. If the affected table does not contain an IDENTITY column, @@identity is set to 0.





Copyright © 2005. Sybase Inc. All rights reserved. Checking the transaction nesting level with @@trancount

View this book as PDF