Tuesday, March 27, 2012

@@Error and @@RowCount

DECLARE @.ErrorNum INT
, @.RowCount INT
DELETE Seller
WHERE SellerId = 9999999999999
SELECT @.ErrorNum = @.@.ERROR
, @.RowCount = @.@.ROWCOUNT
SELECT @.RowCount
, @.ErrorNum
Cases @.ErrorNum @.RowCount
1 0 0
2 0 <> 0
3 <> 0 0
4 <> 0 <> 0
I can simulate the Case 1 and 2 but not case 3 and 4
1 Not able to simulate the problem if the @.ERRORNUM <> 0
2 Checking @.@.ERROR and @.@.ROWCOUNT in the above sample code is correct.
can you please some one help me how to simulate the case 3 and 4
Thanks in Advance
Rajesh.Insert a row into the table & you can simulate #3:
CREATE TABLE Seller ( SellerId BIGINT PRIMARY KEY ) ;
Case #1
-- No rows in the table
DECLARE @.ErrorNum INT, @.RowCount INT
DELETE Seller WHERE SellerId = 9999999999999
SELECT @.ErrorNum = @.@.ERROR, @.RowCount = @.@.ROWCOUNT
SELECT @.RowCount, @.ErrorNum ;
GO
Case #2
DECLARE @.ErrorNum INT, @.RowCount INT
DELETE Seller WHERE SellerId = 9999999999999 /0
SELECT @.ErrorNum = @.@.ERROR, @.RowCount = @.@.ROWCOUNT
SELECT @.RowCount, @.ErrorNum ;
GO
Case #3
INSERT Seller SELECT 9999999999999
DECLARE @.ErrorNum INT, @.RowCount INT
DELETE Seller WHERE SellerId = 9999999999999
SELECT @.ErrorNum = @.@.ERROR, @.RowCount = @.@.ROWCOUNT
SELECT @.RowCount, @.ErrorNum ;
GO
Anith|||Issue resolved.
@.@.Error I am checking for the compliation errors
whereas I need to check for the execution errors
Thanks & Regards
Rajesh.
"Rajesh" wrote:

> DECLARE @.ErrorNum INT
> , @.RowCount INT
> DELETE Seller
> WHERE SellerId = 9999999999999
> SELECT @.ErrorNum = @.@.ERROR
> , @.RowCount = @.@.ROWCOUNT
> SELECT @.RowCount
> , @.ErrorNum
> Cases @.ErrorNum @.RowCount
> 1 0 0
> 2 0 <> 0
> 3 <> 0 0
> 4 <> 0 <> 0
> I can simulate the Case 1 and 2 but not case 3 and 4
> 1 Not able to simulate the problem if the @.ERRORNUM <> 0
> 2 Checking @.@.ERROR and @.@.ROWCOUNT in the above sample code is correct.
>
> can you please some one help me how to simulate the case 3 and 4
> Thanks in Advance
> Rajesh.
>sql

No comments:

Post a Comment