@@error and @@transtate

Results 1 to 2 of 2

Thread: @@error and @@transtate

  1. #1
    Join Date
    Dec 1969

    Default @@error and @@transtate

    Would you tell me when to use which variable to check for error?

  2. #2
    Join Date
    Dec 1969

    Default RE: @@error and @@transtate

    Upon the completion of any T-SQL statement, SQL Server sets the @@ERROR object. If the statement was successful, @@ERROR is set to 0, otherwise it is set to the designate error code. <BR><BR>The global variable @@transtate keeps track of the current state of a transaction. SQL Server determines what state to return by keeping track of any transaction changes after a statement executes. @@transtate may contain the following values:<BR><BR>0<BR> Transaction in progress: an explicit or implicit transaction is in effect; the previous statement executed successfully.<BR> <BR>1<BR> Transaction succeeded: the transaction completed and committed its changes.<BR> <BR>2<BR> Statement aborted: the previous statement was aborted; no effect on the transaction.<BR> <BR>3<BR> Transaction aborted: the transaction aborted and rolled back any changes.<BR> <BR>SQL Server does not clear @@transtate after every statement. You can use @@transtate after a statement (such as an insert) to determine whether it was successful or aborted and to determine its effect on the transaction.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts