如果检测SQL服务器正在运行 [英] Detecting if SQL server is running

查看:98
本文介绍了如果检测SQL服务器正在运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方式来轮询不同的服务器,并检查SQL服务器是否正常运行。我正在写在C#我的代码。我并不特别在意个人的数据库,只是SQL服务器正在运行和响应。

I'm looking for a way to poll different servers and check that SQL server is up and running. I'm writing my code in C#. I don't particularly care about individual databases, just that SQL server is running and responsive.

任何想法?

推荐答案

那么,蛮力解决方案是试图发起与每台服务器上的数据库的连接。这将告诉你它是否在运行,但你可以有超时问题。

Well, the brute force solution is to attempt to initiate a connection with the database on each server. That will tell you whether it's running, though you could have timeout issues.

更优雅(但较难......是不是总是这样?)解决方案是使用WMI连接到远程计算机,看看SQL服务器进程正在运行。

The more elegant (but more difficult... isn't that always the way?) solution would be to use WMI to connect to the remote machine and find out if the SQL server process is running.

这篇关于如果检测SQL服务器正在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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