I must be missing something, so figure I'll ask here. I thought the basic premise of a TRY/CATCH block is the TRY is the first event, and if it errors out, instead of just erroring out, you can then do the CATCH piece. But I am going nowhere with getting anything useful from that setup.
Here's what I'm trying to do:
I tried it without the cross server portion by using the EXEC command as well, and that gets same results.
Am I missing something? is there a keyword I need to use to get this to work? Or do I need to go another route altogether?
The issue is that the schema name will work differently on different servers, at least with the particular server we're linking to in this instance. So my end goal is that I want to be able to figure out what the schema is, or at least be able to send the SELECT query to the correct schema when the table runs.
Thanks in advance for any suggestions.
"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
Here's what I'm trying to do:
Code:
BEGIN TRY
SELECT TOP 1 1 ,'LongName' FROM CrossServer01.[MYDOMAIN\myusername].MyTable
END TRY
BEGIN CATCH
SELECT TOP 1 1 ,'ShortName' FROM CrossServer01.myusername.MyTable
END CATCH
I tried it without the cross server portion by using the EXEC command as well, and that gets same results.
Am I missing something? is there a keyword I need to use to get this to work? Or do I need to go another route altogether?
The issue is that the schema name will work differently on different servers, at least with the particular server we're linking to in this instance. So my end goal is that I want to be able to figure out what the schema is, or at least be able to send the SELECT query to the correct schema when the table runs.
Thanks in advance for any suggestions.
"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57