query for data file sizes on a server

  • I have done this many times before but have forgotten the simple statement, can someone assist me with the query we run against master and returns lists all data, log files on that server and their sizes?

    thank you

  • sp_msForEachdb 'USE ?

    EXEC sp_helpfile'

    It's not exactly what you were asking, but it goes very close, I think.

    -- Gianluca Sartori

  • Another way to get it in a single result set:

    select top 0 *

    into #files

    from sysfiles

    EXEC sp_msforeachdb 'insert into #files select * from ?.dbo.sysfiles'

    select * from #files

    drop table #files

    -- Gianluca Sartori

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply