I have a huge script for creating tables and porting data from one server. So this sceipt basically has -
Avoid direct references to '@@ERROR'. It's a flighty little thing that can be lost.
Declare @ErrorCode int; ... perform stuff ... Set @ErrorCode = @@ERROR; ... other stuff ... if @ErrorCode ......