• Use this bit to get the results without using a cursor. Replace <<mydb>> with a database that exists on your server.

    if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FileDetails]') 
          and OBJECTPROPERTY(id, N'IsUserTable') = 1)
     BEGIN
    
    CREATE TABLE dbo.FileDetails (     
    FileId int
    , FileGroupId int
    , TotalExtents int
    , UsedExtents int
    , Name nvarchar( 128 )
    , FileName nvarchar( 500 )
    , TotalSize AS ( ( TotalExtents * 64.0 ) / 1024 ) 
    , UsedSize AS ( ( UsedExtents * 64.0 ) / 1024 )
    )    
    END

    exec master..sp_MSforeachdb 'USE ?
    INSERT INTO <<mydb>>.dbo.FileDetails (FileId, FileGroupId, TotalExtents, UsedExtents, Name, Filename)
    EXEC(''DBCC showfilestats'')'
    SELECT * FROM <<mydb>>.dbo.FileDetails

     

    --------------------
    Colt 45 - the original point and click interface