what does the second @@error return?

  • Second error return 50000

    (1 row(s) affected)

    Msg 50000, Level 16, State 1, Line 2

    oh no, error!

    (1 row(s) affected)

    (1 row(s) affected)

    Msg 50000, Level 16, State 1, Line 6

    oh no, another error!

    (1 row(s) affected)

  • Return 0 because there is a statement between (select 'xyz'), and this statement do not raise error

  • Lynn Pettis (4/26/2010)


    What is interesting is that approximately a third of the respondents have gotten the question wrong.

    I'm amongst that respondents because I haven't used @@error since 2006, and I've already forgotten about this function 🙂

  • Select 'xyz' will not return any error.

    so @@error return 0

  • Thanx Dear for ur ans.

    Thanks
    SUrya

  • @@error will have the right error code if selected immediately after raiserror command

    raiserror('oh no, another error!', 16,1)

    select @@error

    Thanks

    Igor Micev,
    My blog: www.igormicev.com

  • Previous question also same like this.... easy only.....

    Manik

    Go fast as possible

    Manik
    You cannot get to the top by sitting on your bottom.

  • Hi,

    I executed this code in SQL Serve 2012 and I received the errors sequence:

    (1 row(s) affected)

    Msg 50000, Level 16, State 1, Line 2

    oh no, error!

    (1 row(s) affected)

    (1 row(s) affected)

    Msg 50000, Level 16, State 1, Line 6

    oh no, another error!

    (1 row(s) affected)

    (1 row(s) affected)

    I answered 50.000

Viewing 8 posts - 16 through 22 (of 22 total)

You must be logged in to reply to this topic. Login to reply