Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I detached a database in SQL Server 2008 but am unable to find the physical file to move. Where is this located?

share|improve this question
up vote 2 down vote accepted

There's no guarantee that this is where the file will be, but the default location is:

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\

This is the default default, but it can be changed to a different default. The quickest way to check this is in the SSMS, connect to the server, right-click the server in the Object Explorer, go to Properties and then go to the Databases pane, and the defaults are listed in there.

(you might have a different instance name from MSSQL.1, and if you're running 32-bit SQL on Windows 64-bit then it'll be Program Files (x86)

share|improve this answer
Ah, perfect. I went into properties of the server to find the location. Thanks! – kylehayes Nov 3 '10 at 2:32

Since your default location can be changed AND the initial location depends upon where you select in the installation, there is no correct answer here. You can list all your current database file locations by :-

select * from sys.master_files

And list your default locations through T-SQL you can currently use

EXEC @rc = master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE',N'Software\Microsoft\MSSQLServer\MSSQLServer',N'DefaultLog', @dir output, 'no_output'

EXEC @rc = master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE',N'Software\Microsoft\MSSQLServer\MSSQLServer',N'DefaultData', @dir output, 'no_output'

Please note these two commands above may be replaced in future iterations of SQL Server.




share|improve this answer

I hope this is the answer you are looking for System and Sample Databases

The default location of the database and log files isProgram Files\Microsoft SQL Server\MSQL10.<InstanceName>\MSSQL\. This location will change if the default directory was changed when SQL Server was installed.

share|improve this answer

Depend on your database configuration. Are you using cluster mode or single server ? It will be located on different location for each files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.