Welcome to

SqlServer-QA.net

Sign in | Join | Help

TSQL to get default location of database data and log files?

By default the SQL Server database data & log files are created on the default data directory which is Program Files or based on where SQL binary files are installed.
 
In order to find what is the default location you can run following TSQL:

declare @SmoDefaultFile nvarchar(512)
exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer', N'DefaultData', @SmoDefaultFile OUTPUT

declare @SmoDefaultLog nvarchar(512)
exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer', N'DefaultLog', @SmoDefaultLog OUTPUT

SELECT ISNULL(@SmoDefaultFile,N'') AS [DefaultFile], ISNULL(@SmoDefaultLog,N'') AS [DefaultLog]
Published Tuesday, January 08, 2008 5:37 AM by SQL Master

Comments

# TSQL to get default location of database data and log files?

By default the SQL Server database data & log files are created on the default data directory which

Tuesday, January 08, 2008 6:30 AM by SSQA.net - SqlServer-QA.net

# TSQL to get default location of database data and log files?

By default the SQL Server database data & log files are created on the default data directory which

Tuesday, January 08, 2008 6:34 AM by Other SQL Server Blogs around the Web

# Default Data location | keyongtech

Sunday, January 18, 2009 10:19 AM by Default Data location | keyongtech
Anonymous comments are disabled