I have some stored procs that reference a few linked servers in a distributed transaction. This works OK in live, but in my DR location I have fewer actual machines, and they contain databases that reside on separate machines in live.
Under the circumstances, i would have to use loop-back linked server names in DR, which would kill the distributed trans, or I would have to have two versions of the code - for DR and Live, that reference actual machine names - which pretty much defeats the purpose of disaster recovery.
I have tried solving the issue by adding conditions like
IF @@SERVERNAME = 'SQLPROD1' EXEC SQLPROD2.MyDB.dbo.mySP
ELSE EXEC SQLDR2.MyDB.dbo.mySP
Problem with that is - if either SQLPROD2 or SQLDR2 is offline - the SP fails, because referential integrity is validated at "prepare", and an inaccessible server throws an error, even though it would not be actually referenced at all at execution.
Is there a way of adding conditional statements that would be evaluated at "prepare" stage?
Or perhaps someone could suggest a different way of achieving what I am after?