CAMSYSTEMS
asked on
SQL Server 2005 Database File Path (mdf ldf files)
Is there a way from an SQL Server 2005 query to find out the path of the Database Files (mdf and ldf files).
I can get this information from right clicking on the database, going to properties and then to Files but I need to get this information using a query to use as part of a backup query.
Any ideas
I can get this information from right clicking on the database, going to properties and then to Files but I need to get this information using a query to use as part of a backup query.
Any ideas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Is there anyway of getting just the path (without the filename) or do I have to get a substring of the physical_name?
you need to use substring for this
use adventureworks
go
select substring(physical_name,1, charindex( [name],phy sical_name )-1)
from sys.database_files
go
select substring(physical_name,1,
from sys.database_files
if you need it without the last backslash [\], change -1 to -2
:-)
:-)
sp_HelpFile 'dbNAME'