Home > DeveloperSection > Interviews > How to get @@error and @@rowcount at the same time?

Posted on    May-11-2011 5:01 AM

 MSSQL Server MSSQL Server 
 1 Answer(s)
  1509  View(s)
Rate this:

Awadhendra Tiwari

Total Post:510

Posted on    May-11-2011 12:00 AM

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

Don't want to miss updates? Please click the below button!

Follow MindStick