This is a conceptual question to start with. I have a co-worker having trouble w/ an import script. He is pulling in data from an old AS400 system into SQL Server 2008. It works for a few hours then blows up somewhere for different reasons, ie field in an incoming table is too long, connection timed out, etc. He is asking me if there is a way to tweak his script which I don't have just yet to use some error handling, document the error, and then just move onto the next table to import so we don't have to babysit this thing. Is this possible? Should I look into @@Error?
If the script is in T-SQL then use TRY...CATCH. @@ERROR is legacy crap from SQL2k minus - it did not allow error handling but only some error detection and post error conditional control flow. I don't think I have used @@ERROR once since moving on to SQL Server 2005 plus.