Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding File Path of a database file (mdf)

Status
Not open for further replies.

jstiegelmeyer

Programmer
Dec 31, 2002
27
US
Does anyone know of a stored procedure that I can use to determine the file path of an attached db file?

Essentially, I need to be able to use ADO in VB 6.0 to determine the path of the db file, so any stored procedure that can be used in Query Analyzer would work.

Thanks in advance,
Jamie
 
SELECT RTRIM(filename)
FROM YourDatabaseName.dbo.SysFiles
WHERE Name = 'YourDatabaseName_Data'

Thanks

J. Kusch
 
Excellent, thanks JayKusck!

In case anyone else uses this for reference, let me correct a typo ("Dat" instead of "Data"):

SELECT RTRIM(filename)
FROM YourDatabaseName.dbo.SysFiles
WHERE Name = 'YourDatabaseName_Dat'

Also, you can get more DB info if you use

SELECT *
FROM YourDatabaseName.dbo.SysFiles

Thanks again!
 
or
sp_helpdb 'your database name'
give you information about the specified database

Matt

Brighton, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top