61 reputation
4
bio website
location United Kingdom
age
visits member for 1 year, 9 months
seen Nov 18 '13 at 13:39

Nov
15
awarded  Self-Learner
Jul
23
awarded  Teacher
Apr
9
awarded  Popular Question
Mar
7
answered Linked server error not caught by TRY-CATCH
Mar
7
comment Linked server error not caught by TRY-CATCH
Gah, when I added the PRINT I still had the sp_testlinkedserver call in the script. In actual fact, it doesn't get printed using my original (failing) script. So it looks like this is actually a compile-time error, which is why it doesn't get caught.
Mar
7
comment Linked server error not caught by TRY-CATCH
@AaronBertrand If you add a simple PRINT 'Start'; at the very top of the script, this gets printed in the output, even though the connection then fails and the script exits with the error. So this would indicate a runtime error wouldn't it? Unless I'm misunderstanding it?
Mar
7
comment Linked server error not caught by TRY-CATCH
Thanks Aaron, didn't know about sp_testlinkedserver
Mar
7
comment Linked server error not caught by TRY-CATCH
Thanks Max. Yes, I had thought of dynamic SQL (and the above does indeed work correctly). I am interested in WHY the error isn't caught though?
Mar
7
awarded  Student
Mar
7
asked Linked server error not caught by TRY-CATCH