Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ekareem
Starting Member
9 Posts |
Posted - 2006-03-31 : 16:57:55
|
| Hi,I ran the following code and got @rows to display the value 1 - I guess it should display 0 because the IF statement returns no rows of course - So why is it displaying 1?DECLARE @ERRORS INTSELECT 5,10,15 IF @@ERROR > 0 SET @ERRORS=1ELSE SET @ERRORS=0SELECT 'ROW_Count', @@ROWCOUNT --> shows 1 !! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-03-31 : 17:15:59
|
| It returns 1 because the statement SET @ERRORS=0 returns 1 row. You'll want to put the value of @@ERROR and @@ROWCOUNT into variables all in one statement to avoid this issue.DECLARE @e int, @rc int...SELECT @e = @@ERROR, @rc = @@ROWCOUNTTara Kizeraka tduggan |
 |
|
|
ekareem
Starting Member
9 Posts |
Posted - 2006-04-02 : 01:21:42
|
| Very clever. Thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|