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 Development (2000)
 SQL SERVER 2005 Default Directory

Author  Topic 

hrishi_des
Yak Posting Veteran

76 Posts

Posted - 2006-11-29 : 00:43:51
How to find programmatically default directory for data files in SQL SERVER 2005?

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2006-11-29 : 01:49:21
[code]
declare @file nvarchar(512)
exec master.dbo.xp_instance_regread
N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer',
N'DefaultData',
@file OUTPUT

select @file
[/code]
log location is similar, but pass N'DefaultLog' instead.


SqlSpec: a fast and comprehensive data dictionary generator for
SQL Server 2000/2005, Analysis Server 2005, Access 97/2000/XP/2003
http://www.elsasoft.org
Go to Top of Page

hrishi_des
Yak Posting Veteran

76 Posts

Posted - 2006-11-29 : 02:05:53
Many thanks jezemine for a quick reply,
we are using the same approach.The registry key value has changed to
HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft Sql Server\MSSQL.1\MSSQLServer\DefaultData in SQL SERVER 2005.

Wanted to know if there is any other way for doing this.

Best Regards,
Hrishi.

Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2006-11-29 : 02:12:56
the only instance-aware way to read the registry that I know of is to use xp_instance_regread.


SqlSpec: a fast and comprehensive data dictionary generator for
SQL Server 2000/2005, Analysis Server 2005, Access 97/2000/XP/2003
http://www.elsasoft.org
Go to Top of Page
   

- Advertisement -