top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to get @@ERROR and @@ROWCOUNT at the Same Time?

+1 vote
512 views
How to get @@ERROR and @@ROWCOUNT at the Same Time?
posted Sep 4, 2014 by Khusboo

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes
 
Best answer

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 do both in same statement and store them in local variable. SELECT @RC = @@ROWCOUNT, @ER = @@ERROR

answer Sep 4, 2014 by Pardeep Kohli
Similar Questions
+1 vote

I need to access in-memory representation of both the source program(the program before compilation) and target program(the program after compilation) at the same time. If I add a plugin between two passes,say p1 and p2, I will be able to access the program produced by only p1 but I would neither be able to access the program which was before executing p1 nor the program after p2. I want to compare the programs before and after compilation. How to do that?

0 votes

I got this problem with a SQL Server table, got this example table named "sales" that shows the sales per day for each vendor
this is the current table:
+-------+-----------+-----------+--------------+
| id | vendor | sales | date |
+-------+-----------+-----------+--------------+
| 1 | John | 10 | 07-20 |
| 2 | John | 5 | 07-20 |
| 3 | Jeff | 15 | 07-21 |
| 4 | Jeff | 20 | 07-21 |
| 5 | John | 5 | 07-21 |
| 5 | Jeff | 30 | 07-20 |

and I would like to transform it into this table below I need to group by vendor and compare the columns of the sales for each day
+-----------+--------------+-------------------+-----------
| vendor |sales 07/20 | sales 07/21 | Variance |
+-----------+--------------+-------------------+-----------
| John | 15 | 5 | -10 |
| Jeff | 30 | 35 | 5 |

...