There are multiple instances of SQL Server 2005 installed on a box. Is there a T-SQL query I can run from Studio that will detect these other instances and their names?
在一个盒子上安装了多个SQL Server 2005实例。是否有可以从Studio运行的T-SQL查询,它将检测这些其他实例及其名称?
2 个解决方案
#1
I highly doubt there's a query you can run to find out instances (you need to be connected to one to run queries) but SQL Server Surface Area Configuration (under Start Menu-->Microsoft SQL Server 2005 --> Configuration Tools) will show you all the instances you have on a given machine.
我非常怀疑你可以运行一个查询来查找实例(你需要连接到一个运行查询)但SQL Server表面区域配置(在开始菜单 - > Microsoft SQL Server 2005 - >配置工具下)将显示你在给定机器上的所有实例。
An alternative might be doing it from code - see this article.
另一种方法是从代码中执行此操作 - 请参阅此文章。
#2
I figured out a cheat. It requires using xp_cmdshell and the net start command. I don't know anything about using the net start command and what negative implications that might have. Can anyone advise on that?
我想出了一个骗子。它需要使用xp_cmdshell和net start命令。我对使用net start命令以及可能产生的负面影响一无所知。任何人都可以提出建议吗?
create table #test ( srvcs varchar(2000) )
;
insert into #test
exec master..xp_cmdshell 'net start'
;
select
substring( srvcs, charindex( '(', srvcs ) + 1, (charindex( ')', srvcs ) - charindex( '(', srvcs ) - 1) )
as srvcs
from #test
where ltrim(srvcs) like '%SQL Server (%'
;
drop table #test
;
#1
I highly doubt there's a query you can run to find out instances (you need to be connected to one to run queries) but SQL Server Surface Area Configuration (under Start Menu-->Microsoft SQL Server 2005 --> Configuration Tools) will show you all the instances you have on a given machine.
我非常怀疑你可以运行一个查询来查找实例(你需要连接到一个运行查询)但SQL Server表面区域配置(在开始菜单 - > Microsoft SQL Server 2005 - >配置工具下)将显示你在给定机器上的所有实例。
An alternative might be doing it from code - see this article.
另一种方法是从代码中执行此操作 - 请参阅此文章。
#2
I figured out a cheat. It requires using xp_cmdshell and the net start command. I don't know anything about using the net start command and what negative implications that might have. Can anyone advise on that?
我想出了一个骗子。它需要使用xp_cmdshell和net start命令。我对使用net start命令以及可能产生的负面影响一无所知。任何人都可以提出建议吗?
create table #test ( srvcs varchar(2000) )
;
insert into #test
exec master..xp_cmdshell 'net start'
;
select
substring( srvcs, charindex( '(', srvcs ) + 1, (charindex( ')', srvcs ) - charindex( '(', srvcs ) - 1) )
as srvcs
from #test
where ltrim(srvcs) like '%SQL Server (%'
;
drop table #test
;