Solved

Knowing where database files are placed SQL 2008

Posted on 2013-01-16
3
293 Views
Last Modified: 2013-01-18
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?
0
Comment
Question by:itnifl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 57

Assisted Solution

by:Raja Jegan R
Raja Jegan R earned 65 total points
ID: 38786112
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
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 65 total points
ID: 38786116
the entry point is the master database; of which the location is specified in the startup options:
http://msdn.microsoft.com/en-us/library/ms190737%28v=sql.105%29.aspx
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.
0
 
LVL 43

Assisted Solution

by:Eugene Z
Eugene Z earned 65 total points
ID: 38786558
you can pre- record all this info as per above posted info
and \or from registry via , for example, script from
the post
http://sqlandme.com/2012/01/05/sql-server-identifying-default-data-directory-for-multiple-instances-through-registry/
or like this
declare @SQLDataRoot varchar(500)
exec master..xp_instance_regread
   @rootkey='HKEY_LOCAL_MACHINE',
   @key='SOFTWARE\Microsoft\MSSQLServer\Setup',
   @value_name='SQLDataRoot',
   @value=@SQLDataRoot output

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

and\or powershell ,  WMS ,etc
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQLCMD question to have fields created as fixed length 2 36
sql trace 4 26
database audit for object access 6 42
Creating Scalar Function 3 17
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question