Wednesday, March 7, 2012

query on data and log file

If I have to query the two filenames of a database for both data and log fil
e, how can I do
it from master database. One method I know is to use the database and call s
p_helpfile.
But I want the query to run from the masterdb about the data and log file of
a database.
TIA"SQL Server DBA" <sqlsdba@.gmail.com> wrote in message news:3agp50F6cit2sU1@.individual.net...

> If I have to query the two filenames of a database for both data and log f
ile, how can I
> do
> it from master database. One method I know is to use the database and call
sp_helpfile.
> But I want the query to run from the masterdb about the data and log file of a dat
abase.
The database has only 1 data file and 1 log file.|||dbnane.dbo.sysfiles
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"SQL Server DBA" <sqlsdba@.gmail.com> wrote in message news:3agpefF68pc4bU1@.individual.net...

> "SQL Server DBA" <sqlsdba@.gmail.com> wrote in message news:3agp50F6cit2sU1
@.individual.net...
> The database has only 1 data file and 1 log file.
>|||Use the name of the db to call the sp.
Example:
use master
go
exec pubs..sp_helpfile
exec northwind..sp_helpfile
go
AMB
"SQL Server DBA" wrote:

> "SQL Server DBA" <sqlsdba@.gmail.com> wrote in message news:3agp50F6cit2sU1
@.individual.net...
> The database has only 1 data file and 1 log file.
>|||You can query directly from master.dbo.sysaltfiles table, or run a cursor
through the sysfiles table in each database.
"SQL Server DBA" <sqlsdba@.gmail.com> wrote in message
news:3agpefF68pc4bU1@.individual.net...
> "SQL Server DBA" <sqlsdba@.gmail.com> wrote in message
> news:3agp50F6cit2sU1@.individual.net...
> The database has only 1 data file and 1 log file.
>|||thanks all.
Actually after posting I figured it out myself by reading the source code of
sp_helpfile :-). Geez, I should have done that before posting here.

No comments:

Post a Comment