Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 List System names that sql server installed

Author  Topic 

sundarakshi
Starting Member

1 Post

Posted - 2005-06-30 : 00:26:06
Hi,

I have to list the system names which has sql Server installed. How it can be done in C#.NET.

Help Me Plz
Regards
Somu

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-30 : 01:04:47
Not sure whether this is effient method
Search for the file master.mdf, if it is found, then there is chance SQL Server is installed
Why do you want to do this?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

hgorijal
Constraint Violating Yak Guru

277 Posts

Posted - 2005-06-30 : 06:03:44
Check to see if the SQL Server Service is running....
Now..wait.. I am not asking you to open Services MMC and look for it in every server.
Run this VB Script and parse the results..
(Change the variable in the first line to your server name)


[code]
strComputer = "YOUR_COMPUTER_NAME"
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colRunningServices = objWMIService.ExecQuery("Select * from Win32_Service")

For Each objService in colRunningServices
If Mid(objService.DisplayName,1,5) = "MSSQL" Then
Wscript.Echo objService.DisplayName & VbTab & objService.State
end If
Next
[\code]

Hemanth Gorijala
I Came. I Saw, I Normalized.
Go to Top of Page
   

- Advertisement -