how to detect all sql server instances from studio?
-
23-08-2019 - |
Question
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?
Solution
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.
An alternative might be doing it from code - see this article.
OTHER TIPS
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?
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
;