For example, the SQL statement below:
SELECT Employeeid from Employees - This SQL statement returns 9 records
Print (@@ Error)
Print (@@ rowcount)
The result of returning is:
(9 row affed)
0
0
and
SELECT Employeeid from Employees - This SQL statement returns 9 records
Print (@@ rowcount)
Print (@@ Error)
The result of returning is:
(9 row affed)
9
0
The reason, the latter print is the result of the corresponding variable after the previous print execution.
If you want to execute in a statement, you get @@ RowCount too to get @@ error, you need to read them with a SQL statement:
Declare @a int, @ b int
SELECT Employeeid from Employees - This SQL statement returns 9 records
SELECT @a = @@ rowcount, @ b = @@ error
Print (@A)
Print (@B)
In this reading data, it doesn't matter. That is, SELECT @B = @@ error, @ a = @@ rowcount can also be. But it must be a sentence, if it turns into two sentences, there is a problem.
Declare @a int, @ b int
SELECT Employeeid from Employees - This SQL statement returns 9 records
SELECT @B = @@ error
SELECT @a = @@ rowcount
Print (@A)
Print (@B)
Return the result:
(9 row affed)
1
0
Declare @a int, @ b int
SELECT Employeeid from Employees - This SQL statement returns 9 records
SELECT @a = @@ rowcount
SELECT @B = @@ error
Print (@A)
Print (@B)
Return the result:
(9 row affed)
9
0