Hi Vijay
When I try to execute the SELECT statement for some non-existent table I get the following error message:
Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'fergegeg'.
But the crucial thing is that after displaying this message the remaining code following the EXEC command also executes, so I can include some error handling code to take an alternative course of action, do any clean up, etc. All well and good.
However, if my error is generated instead by some comms failure, eg I'm trying to SELECT from a table on another machine and my network cable is unplugged, I get the following error.
Server: Msg 11, Level 16, State 1, Line 1
General network error. Check your network documentation.
[OLE/DB provider returned message: Unspecified error]
Unfortunately after getting this error Query Analyser immediately exits the script without executing any of the remaining code - in other words any error handling I might have included gets ignored.
The question is, how do I deal with errors caused by network failure? Or alternatively is there any way of testing a server connection before attempting to run queries against it?
Thanks
|