Question : sql server 2000 @@ERROR variable wrong result

that is, @@ERROR return 0 event that there was an error in the query.

the query is an update query that should fail if there is a violation in the primary key (duplicate).and it actually is being aborted (no records updated) despite that, @@error variable return 0;

the primary key is configured to ignore duplicates, this is, it wont insert records that violates the primary key rule. this work fine.

I wonder if 'Ignore duplicates' has something to do, but Im pretty sure it was working the way it should some time ago.

hope this make sense.

regards.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
FETCH NEXT FROM modelid1 INTO @query, @queryIDIndex 

WHILE @@FETCH_STATUS = 0 
  BEGIN 
      BEGIN TRAN tran1 

      EXEC (@query) 

      IF @@ERROR <> 0 
        UPDATE md_querys_queue 
        SET    completed = 0 
        WHERE  queryid = @queryIDIndex 
               AND location = @LOCATION 
      ELSE 
        UPDATE md_querys_queue 
        SET    completed = 1 
        WHERE  queryid = @queryIDIndex 
               AND location = @LOCATION 

      COMMIT TRAN tran1 

      FETCH NEXT FROM modelid1 INTO @query, @queryIDIndex 
  END

Answer : sql server 2000 @@ERROR variable wrong result

In the SBS Native Tools console drill into the Computer (Local) console down to the Windows Logs node. In there you will find a custom filter already created for Administrator Events.

That should show you any critical events the server has been experiencing.

Philip
Random Solutions  
 
programming4us programming4us