Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting and Configuration

Status
Not open for further replies.
Nov 4, 2002
107
SG
Hello,

Just a question, is there a way where we can query the path were the sqlserver was installed both System and Data?

The List of Database was located on the sysdatabase under the Master group. Right?

How about the system?

Jerry




 
Hi

The following will return the location of the data file(mdf)
and logfile(ldf) for each database. Each database has a system table called sysfiles which stores that info.

select name, filename
from yourdatabase.dbo.sysfiles

Alternatively you could write a cursor to loop through all the databases.


Hope this helps

John
 
Thanks,

Example .. I am not the one who installed the SQL Server. So I dont know how it was configured. Remember during the installation? We can redirect the Data Path and the System Path of SQL. I am just wondering if there is a way to display the said Path- in any way?


Jerry


 
The path and Data path are stored in the registry under
HKEY_LOCAL_MACHINE\SOFTWARE\MSSQLServer\Setup\SQLPath & SQLDataRoot.
You can get hold of these inside SQL by using The SQL_DMO registry object properties SQLRootPath and SQLDataRoot.
 
You can also use xp_regread as below

Declare @Instpath varchar(50), @Datapath varchar(50)

exec master.dbo.xp_regread @rootkey='HKEY_LOCAL_MACHINE', @key='SOFTWARE\Microsoft\MSSQLServer\Setup',
@value_name='SQLPath',@value=@Instpath output
print @Instpath

exec master.dbo.xp_regread @rootkey='HKEY_LOCAL_MACHINE', @key='SOFTWARE\Microsoft\MSSQLServer\Setup',
@value_name='SQLDataRoot',@value=@Datapath output
print @Datapath
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top