Solved

SQL SERVER instance data location.

Posted on 2013-06-05
3
256 Views
Last Modified: 2013-06-06
Hello All,

I have been asked (instructed) to come up with the code that will provide me with the default data location for a particular server. I am going to allow the user to choose the server and generating a list of servers and databases on the server is not a problem. Once the server is selected I need to retrieve the default data location (file path) for that server. I van not use the SQL Server SMO options. Any suggestions?

Thanks Art
0
Comment
Question by:Nashua58
[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 18

Assisted Solution

by:DarrenD
DarrenD earned 250 total points
ID: 39224927
Hi,

This query should tell you:

SELECT SUBSTRING(filename, 1, CHARINDEX(N'Name of Database.mdf', LOWER(filename)) - 1)
FROM master.dbo.sysdatabases
WHERE name = 'Name of Database'


Cheers,

Darren
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 250 total points
ID: 39225368
Hi,
the above mentioned script will only work if the directory has not been changed after installation as it only returns the location of the master db.
You have to query the registry for this:
http://tenbulls.co.uk/2010/07/08/how-to-set-and-manage-your-sql-server-default-paths/

HTH
Rainer
0
 

Author Closing Comment

by:Nashua58
ID: 39225804
thanks both are working for me
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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