declare @srvr nvarchar(128), @retval int;
set @retval = 0
set @srvr = 'dbname';
begin try
exec @retval = sys.sp_testlinkedserver @srvr; --测试远程连接是否通畅
end try
begin catch
set @retval = sign(@@error);
end catch;
if @retval<>0
begin
--@retval=0说明远程连接通畅,不等于0则杯具
end