rated by 0 users
This post has 0 Replies | 1 Follower

Top 10 Contributor
Male
Posts 33
Md. Elias Hossain Posted: 01-09-2010 5:23 AM

 

How to get @@ERROR and @@ROWCOUNT at the same time?

Hello,

  A nice thing at SQL statement, really should share with which need to get mind while working on T-SQL, please see bellow...

If @@ROWCOUNT is checked after error checking statement then it will have 0 as it would have been reset.

If @@ROWCOUNT 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 as bellow.

 

DECLARE @RC INT,

            @ER INT

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

 

 

Md. Elias Hossain
MCP, MCTS(WEB)
Software Engineer

Page 1 of 1 (1 items) | RSS