Showing posts with label wise. Show all posts
Showing posts with label wise. Show all posts

Wednesday, March 7, 2012

Obtaining PATH to master DB

I need to obtain the path to the master DB in a Wise install script. I know that for SQL2K it is in the registry key:
HKLM\Software\Microsoft\MSSQLServer\Setup

It seems that a SQL2005 installation does not have the same default
directory.

Is there a way to query this from the server itself so I don't have to read the registry?With the usual caveat that it is not a 'best practice' to query the system tables, you can find the answer by executing:

SELECT filename
FROM sysfiles

while connected to the master database. You will get two records. One is the data file, one is the log file. You can narrow the query by adding:

WHERE name = 'master'

Regards,

hmscott

Edit to add: I did verify this against a SQL 2005 instance we are running in development, but it will also work in SQL2K.