MS SQL ping 外部服务器 [英] MS SQL ping external server

查看:29
本文介绍了MS SQL ping 外部服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种不错"的方法来检查网络主机是否已启动使用普通"SQL?我想到了一些特定于 MS-SQL 的命令或者一些从 ping 脚本中获取返回值的命令在服务器本身上.

Is there a 'nice' way to check whether an network host is up making use of 'plain' SQL? I thought of some MS-SQL specific command or maybe some getting the return value from a ping script on the server itself.

有人对此有什么想法吗?

Does anyone has an idea on this?

推荐答案

有两种可能的方式来回答你的问题:1. 您想知道 SQL 服务器是否在任意主机上运行
2. 您想使用某些查询从 SQL 服务器 ping 任意主机.

There's two possible ways to take your answer: 1. you want to know if a SQL server is running on an arbitrary host
2. You want to ping an arbitrary host from a SQL server using some query.

  1. 你可以使用 dariom 的答案.1a.如果您想从另一个 SQL 服务器查询一个 SQL 服务器,最好使用 SQL Server 的链接服务器"功能.

  1. you could use dariom's answer. 1a. if you want to query one SQL server from another, you're better off using the "Linked Servers" functionality of SQL Server.

您可以使用 master.dbo.xp_cmdshell 存储过程来执行 PING,然后将结果作为文本行和状态代码返回.

You can use the master.dbo.xp_cmdshell stored procedure to execute PING, which then returns the results as text rows and a status code.

EXEC master.dbo.xp_cmdshell 'ping 192.168.1.1'

EXEC master.dbo.xp_cmdshell 'ping 192.168.1.1'

这篇关于MS SQL ping 外部服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆