25 January,2013 by Jack Vamvas
Finding the SQL Server default data and log location (or Database default Locations ) is useful. When a CREATE DATABASE command is issued with target location paths explicitly stated , SQL Server will create the data and log files in the default data and log locations.
That’s not always the intended result. For example, the DBA may need to change the location of system files or move all databases due to disk issues or to improve database performance - read more on SQL Server – files and filegroups. Improving database performance
DECLARE @DataLoc nvarchar(2000);
DECLARE @LogLoc nvarchar(2000);
EXEC master.dbo.xp_instance_regread
N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer',
N'DefaultData',
@DataLoc OUTPUT;
EXEC master.dbo.xp_instance_regread
N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer',
N'DefaultLog',
@LogLoc OUTPUT;
SELECT @DataLoc AS 'Default Data Location',
@LogLoc AS 'Default Log Location';
sql server scripts and managing databases - SQL Server DBA
Operations DBA description - SQL Server DBA
SQL Server 2005 and SQL Server 2008 Upgrade tasks
SQL Server – Tempdb move files to another drive - SQL Server DBA
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |