Solved

Get path and name of data file and log file for a given sql 2000 database

Posted on 2008-10-29
6
259 Views
Last Modified: 2012-05-05
Hi

For doing a restore with move I need to be able to ask any given database what its datafile (Mdf) and its logfile (ldf) is.
So I need to query the server and get these two pieces of information.
How do I do that?

(SQL server 2000)
0
Comment
Question by:liversen
6 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 250 total points
ID: 22830473
if you have the backup you can do this:

restore filelistonly from disk = 'c:\backupfile.bak'

if you just want to see the files for a particular db:

select * from sysfiles
0
 
LVL 5

Assisted Solution

by:Cvijo123
Cvijo123 earned 250 total points
ID: 22830474
is this what u need ?

exec sp_helpfile
0
 
LVL 1

Author Closing Comment

by:liversen
ID: 31511127
Thanks guys. Both solutions are valid.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 7

Expert Comment

by:Cedric_D
ID: 22830631
I think

select * from sysdatabases where name = 'DBNAME'

is more appropriate.
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 22830656
Actually its not.  That query only shows the data file location...it doesn't include the log file.
0
 
LVL 1

Author Comment

by:liversen
ID: 22830704
Just so that you know:

I have chosen to do this:

SELECT filename FROM MYDATABASE.dbo.sysfiles

and it does what I need. thanks again.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now