Wednesday, August 22, 2012

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, include both in same statement and store them in a local variable.

SELECT @RC = @@ROWCOUNT, @ER = @@ERROR

No comments:

Post a Comment