My Blog List

hotinit.com. Powered by Blogger.

Search This Blog

Check Linked Server whether its active

Thursday, 19 May 2011

i.Through Ping Command

Declare @status int
EXEC @status=master.dbo.xp_cmdshell 'ping 172.19.1.4 -n 1',no_output
Select @status
GO
 
ii.DECLARE @srvr NVARCHAR(128), @statusval INT;
SET @srvr = '172.19.1.1\SQLEXPRESS';
BEGIN  TRY
  EXEC @statusval = sp_testlinkedserver @srvr;END
TRY
BEGIN CATCH
SET @statusval = SIGN(@@ERROR);END
CATCH;
IF @statusval <> 0
RAISERROR('Unable to connect to linked server. Try later!', 16, 2 );

No comments:

Post a Comment

 

Blogger news

Blogroll

Most Reading

8.6/10