我试图确定我已经安装的sql server/sql express的实例(手动或编程),但所有的例子都告诉我运行一个sql查询来确定这假设我已经连接到一个特定的实例。
当前回答
我知道这个帖子有点老了,但在我找到我正在寻找的答案之前,我就看到了这个帖子,我想分享一下。如果您正在使用SQLExpress(或localdb),有一种更简单的方法来查找实例名。 在命令行类型中:
> sqllocaldb i
这将列出您在本地安装的实例名。因此,您的完整服务器名称应该在要连接的实例名称前面包含(localdb)\。此外,sqllocaldb允许您创建或删除实例以及配置它们。参见:SqlLocalDB Utility。
其他回答
安装的所有实例都应该显示在Microsoft管理控制台的服务管理单元中。如果需要获取实例名,请执行“开始|运行|类型的服务”。查找所有带有“Sql Server(实例名)”的条目。
在命令行中:
SQLCMD -L
or
OSQL -L
(注:必须大写L)
这将列出网络上安装的所有sql server。您可以设置一些配置选项来防止SQL Server显示在列表中。要做到这一点…
在命令行:
svrnetcn
在启用的协议列表中,选择“TCP/IP”,然后单击属性。有一个“隐藏服务器”的复选框。
If you just want to see what's installed on the machine you're currently logged in to, I think the most straightforward manual process is to just open the SQL Server Configuration Manager (from the Start menu), which displays all the SQL Services (and only SQL services) on that hardware (running or not). This assumes SQL Server 2005, or greater; dotnetengineer's recommendation to use the Services Management Console will show you all services, and should always be available (if you're running earlier versions of SQL Server, for example).
If you're looking for a broader discovery process, however, you might consider third party tools such as SQLRecon and SQLPing, which will scan your network and build a report of all SQL Service instances found on any server to which they have access. It's been a while since I've used tools like this, but I was surprised at what they found (namely, a handful of instances that I didn't know existed). YMMV. You might Google for details, but I believe this page has the relevant downloads: http://www.sqlsecurity.com/Tools/FreeTools/tabid/65/Default.aspx
我也有同样的问题。“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.
命令OSQL -L和sqlmd -L将显示网络上的所有实例。
如果你想要一个服务器上所有实例的列表,并且不喜欢编写脚本或编程,可以这样做:
启动Windows任务管理器 勾选“显示来自所有用户的进程”或相同的复选框 按照“映像名称”对进程进行排序 找到所有sqlsrvr.exe映像
实例应该在“用户名”列中以MSSQL$INSTANCE_NAME的形式列出。
我从认为这个可怜的服务器正在运行63个实例,到意识到它正在运行3个实例(其中一个在CPU负载方面表现得完全像个恶霸……)
推荐文章
- 如何改变SQL在“编辑前200行”在SSMS 2008
- 截断SQL Server日志文件的命令是什么?
- 作为变量的表名
- 是否可以直接选择EXISTS作为位?
- SQL JOIN vs IN性能?
- SQL的地方. .IN子句多列
- 修改表:如何将“允许空”属性从不空改为允许空
- 比较两个SQL Server数据库(模式和数据)的最佳工具是什么?
- 在SQL中,如何在范围中“分组”?
- 选项(RECOMPILE)总是更快;为什么?
- 设置数据库从单用户模式到多用户
- 我如何转义一个百分比符号在T-SQL?
- SQL Server恢复错误-拒绝访问
- 如何在SQL Server Management Studio中查看查询历史
- SQL Server索引命名约定