Try catch along with the function to check the linked server helped me . The function to check the linked server connection is available in the link below http://stackoverflow.com/questions/3104186/sql-server-is-there-an-if-exists-test-for-a-linked-server
– shiny pDec 14 '12 at 20:16