Tuesday, March 27, 2012

Determine physical file names of database

Hi,
How do I determine the physical file names of an SQL Server database
using a query?
For example, I'm looking for a query that returns the following:
Logical Name Physical Name
---
ABC_Data C:\MSSQL7\data\ABC_Data.MDF
ABC_Log C:\MSSQL7\data\ABC_Log.LDF
GeorgeHi
use pubs
exec sp_helpfile
"George" <gtog@._no___spam_myrealbox.com> wrote in message
news:eGpg$VFYFHA.1404@.TK2MSFTNGP09.phx.gbl...
> Hi,
> How do I determine the physical file names of an SQL Server database
> using a query?
> For example, I'm looking for a query that returns the following:
> Logical Name Physical Name
> ---
> ABC_Data C:\MSSQL7\data\ABC_Data.MDF
> ABC_Log C:\MSSQL7\data\ABC_Log.LDF
> George|||You can use sp_helpdb 'YourDatabase'
You could also query sysfiles:
select name, filename
from sysfiles
-Sue
On Tue, 24 May 2005 13:41:17 +0200, George
<gtog@._no___spam_myrealbox.com> wrote:

>Hi,
>How do I determine the physical file names of an SQL Server database
>using a query?
>For example, I'm looking for a query that returns the following:
>Logical Name Physical Name
>---
>ABC_Data C:\MSSQL7\data\ABC_Data.MDF
>ABC_Log C:\MSSQL7\data\ABC_Log.LDF
>George|||SELECT NAME,FILENAME FROM SYSFILES
exec SP_HELPDB <db>
"George" wrote:

> Hi,
> How do I determine the physical file names of an SQL Server database
> using a query?
> For example, I'm looking for a query that returns the following:
> Logical Name Physical Name
> ---
> ABC_Data C:\MSSQL7\data\ABC_Data.MDF
> ABC_Log C:\MSSQL7\data\ABC_Log.LDF
> George
>|||Hi,
Execute the below query from master database:-
select db_name(dbid) as Database_name , name,filename from
master..sysaltfiles
Thanks
Hari
SQL Server MVP
"George" <gtog@._no___spam_myrealbox.com> wrote in message
news:eGpg$VFYFHA.1404@.TK2MSFTNGP09.phx.gbl...
> Hi,
> How do I determine the physical file names of an SQL Server database using
> a query?
> For example, I'm looking for a query that returns the following:
> Logical Name Physical Name
> ---
> ABC_Data C:\MSSQL7\data\ABC_Data.MDF ABC_Log
> C:\MSSQL7\data\ABC_Log.LDF
> Georgesql

No comments:

Post a Comment