我试图确定我已经安装的sql server/sql express的实例(手动或编程),但所有的例子都告诉我运行一个sql查询来确定这假设我已经连接到一个特定的实例。


当前回答

SQL Server浏览器服务http://msdn.microsoft.com/en-us/library/ms181087.aspx

其他回答

另一个选择是运行SQLSERVER发现报告,进入SQLSERVER安装介质,双击setup.exe

在下一个屏幕中,转到工具并单击如下所示的发现报告

这将向你展示所有的实例以及整个功能..下面是我电脑上的快照

如果您有兴趣在脚本中确定这一点,您可以尝试以下方法:

sc \\server_name query | grep MSSQL

注意:grep是gnuwin32工具的一部分

命令OSQL -L和sqlmd -L将显示网络上的所有实例。

如果你想要一个服务器上所有实例的列表,并且不喜欢编写脚本或编程,可以这样做:

启动Windows任务管理器 勾选“显示来自所有用户的进程”或相同的复选框 按照“映像名称”对进程进行排序 找到所有sqlsrvr.exe映像

实例应该在“用户名”列中以MSSQL$INSTANCE_NAME的形式列出。

我从认为这个可怜的服务器正在运行63个实例,到意识到它正在运行3个实例(其中一个在CPU负载方面表现得完全像个恶霸……)

我也有同样的问题。“osql -L”命令只显示服务器列表,但不显示实例名(只显示本地SQL server的实例)。 通过Wireshark, sqlbrowser.exe(可以在SQL安装的共享文件夹中找到),我找到了解决我的问题的方法。

本地实例由注册表项解析。远程实例通过UDP广播(端口1434)和SMB进行解析。 使用"sqlbrowser.exe -c"列出请求。

My configuration uses 1 physical and 3 virtual network adapters. If I used the "osql -L" command the sqlbrowser displayed a request from one of the virtual adaptors (which is in another network segment), instead of the physical one. osql selects the adpater by its metric. You can see the metric with command "route print". For my configuration the routing table showed a lower metric for teh virtual adapter then for the physical. So I changed the interface metric in the network properties by deselecting automatic metric in the advanced network settings. osql now uses the physical adapter.

我刚刚安装了Sql server 2008,但我无法连接到任何数据库实例。 @G Mastros发布的命令没有列出活动实例。

因此,我查看了服务,发现SQL server代理被禁用。我把它设置为自动,然后再启动。