6
Reply

What is @@ERROR?

Raj Kumar M

Raj Kumar M

Jan 29, 2010
5.9k
0

    @@error is a sql server variable which returns error number generated by last query.

    Example:-

    if u run a query and this return error and can't execute.so in long procedure it is much important to rollback transaction .
    Declare @@error_return as  int
    update table_1 set name='Ais' where employeeid='HOM0044' and lastname like 'Singh%'
    set  @error_return=@@error
    if @error_return>0
    ---rollback tran
    else commit tran

    Aishwary Singh
    October 27, 2010
    0

    Dear Raj Kumar
       @@Error is System Variable in Sql Server


    Hirdayanand Mishra
    April 07, 2010
    0

    Heloo Friend!

    This is sql server keyword to represent the error occures during any excution of sql statement and it has 0 for no error ,it has various number for various type of errors

    Thank you!

    Ashish Dwivedi
    March 18, 2010
    0

    It is your pl/sql returning variable that returns current line error details.

    Amit Choudhary
    March 06, 2010
    0

    It is an returning variable in pl/sql that returns the error for the current line.

    Amit Choudhary
    March 06, 2010
    0

    @@ERROR Returns the error number for the last Transact-SQL statement executed.
    When SQL Serversuccessfully completes the execution of a Transact-SQL statement,
    @@ERROR is return 0 if the statement executed successfully. If an error occurs,
     an error message is returned. @@ERROR returns the number of the error message
    until another Transact-SQL statement is executed. You can view the text associated
    with an @@ERROR error number in the sysmessages system table.

    Hirendra Sisodiya
    February 09, 2010
    0