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 HossainMCP, MCTS(WEB) Software Engineer