HOW TO GET @@ERROR AND @@ROWCOUNT AT THE SAME TIME?

Awadhendra Tiwari

Total Post:510

Points:2550
Posted by  Awadhendra Tiwari
 1616  View(s)
Ratings:
Rate this:
  1. Awadhendra Tiwari

    Post:510

    Points:2550
    How to get @@error and @@rowcount at the same time?

    If @@Rowcount is checked after Error checking statement then it will have 0 as the value of @@Recordcount as it would have been reset.
    And if @@Recordcount is checked before the error-checking statement then @@Error would get reset. To get @@error and @@rowcount at the same time do both in same statement and store them in local variable. SELECT @RC = @@ROWCOUNT, @ER = @@ERROR

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!