Interview Questions

How do you find the error, how can you know the number of rows affected by last SQL Statement?

.NET Database ,COM interop,and .NET deployment questions and answers


(Continued from previous question...)

How do you find the error, how can you know the number of rows affected by last SQL Statement?

Answer1
@@errors->give the last error occured in the current DB.
Ans. select @@rowcount

Answer2.
Use @@ERROR which returns the error number for the last Transact-SQL statement executed fro knowing the error.
Use @@ROWCOUNT which returns the number of rows affected by the last statement for finding the no of rows affected.

(Continued on next question...)

Other Interview Questions