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 );
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