Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check If A Connection Is Active

Status
Not open for further replies.

elmo29

Programmer
Jul 28, 2000
50
0
0
GB
Is there any way to check if a connection between 2 SQL Servers exists.

For instance I don't want a sproc to be run unless a connection exists (i.e it could be broken by resetting the computer etc). Is there any way I can do this within code so I can deal with this type of scenario??
 
When you say "connection between 2 SQL Servers" are you referring to a linked server? If so you can check the sysservers table for the existence of a linked server entry.

On server1 you could use the following T-SQL to check if server2 is linked.

If exists (Select * From sysservers where srvname = N'server2')
Begin
<your logic here - server2 link exists>
End
Else
Begin
<exeception logic here - server2 isn't linked>
End
Terry
_____________________________________
Man's mind stretched to a new idea never goes back to its original dimensions. - Oliver Wendell Holmes
 
What I am really talking about is if the connection goes down between the linked servers - like when you reboot the machine etc, it would be good it I could determine that the link has been lost and redirect the information elsewhere.

it seems to me the code you have just checks that there should be a linked server, it doesn't test that the link is live????? is that right??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top