Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SqlServiceAdvancedProperty name to get the install root for Sql Server 2008 using ManagementObjectSearcher?

I'm using a ManagementObjectSearcher to query information about installed Sql Server instances, for example:

 [String].Format("select * from SqlServiceAdvancedProperty 
                   where SQLServiceType = 1 and PropertyName = '{0}' 
                     and ServiceName = '{1}'", propertyName, serviceName)

This method works great for InstanceID, Version and SKUName but now I'm trying to find the installation root as well. For SQL 2005 it appears the property name was SqlDataRoot, but has since been depreciated.

Anybody know the correct property name to use to get the data directory, or even just install directory for Sql Server? Even just a list possible properties that can be queried would be an enormous help.

like image 994
Kosko Avatar asked Dec 10 '25 08:12

Kosko


1 Answers

I looped over each property on a query (that didn't include a specified property) and was able to draw out each name. The property I was looking for is DATAPATH.

For anyone else whose interested, the other possibilities are:

SQLSTATES VERSION SPLEVEL CLUSTERED INSTALLPATH LANGUAGE DATAPATH FILEVERSION VSNAME REGROOT SKU SKUNAME INSTANCEID STARTUPPARAMETERS ERRORREPORTING DUMPDIR SQMREPORTING ISWOW64

like image 141
Kosko Avatar answered Dec 12 '25 02:12

Kosko