• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

Knowing where database files are placed SQL 2008

Is the master database always placed in C:\Program Files\Microsoft SQL Server\MSSQL$<Instancename>\Data ? If the instance is down, how weould I find it if it where placed elsewhere?
Where is the placement of the other attached custom databases stored? Master database? Other places?
3 Solutions
Raja Jegan RSQL Server DBA & ArchitectCommented:
Not necessarily, you can place master and system databases under any location.
If the instance is down, then it would be difficult to identify the files location.
You can use the below query to find the file location of all databases:

select DB_NAME(dbid),* from sys.sysaltfiles
Guy Hengel [angelIII / a3]Billing EngineerCommented:
the entry point is the master database; of which the location is specified in the startup options:
and hence yes, the master db could be anywhere on the disk...

from there, the master db contains the references to the other databases and their files.
Eugene ZCommented:
you can pre- record all this info as per above posted info
and \or from registry via , for example, script from
the post
or like this
declare @SQLDataRoot varchar(500)
exec master..xp_instance_regread
   @value=@SQLDataRoot output

also you can use registry via regedit to find this info as well

and\or powershell ,  WMS ,etc
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now