Link to home
Start Free TrialLog in
Avatar of liversen
liversen

asked on

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

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)
ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of liversen
liversen

ASKER

Thanks guys. Both solutions are valid.
I think

select * from sysdatabases where name = 'DBNAME'

is more appropriate.
Actually its not.  That query only shows the data file location...it doesn't include the log file.
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.