How to get size info for database file using dbcc showfilestats

CREATE TABLE freefilespace
    (
         fileid       INT,
         filegroup    INT,
         totalextents INT,
         usedextents  INT,
         dbname       VARCHAR(256),
         filename     VARCHAR(2000)
    )


INSERT INTO freefilespace
EXEC ('DBCC showfilestats')

SELECT dbname,
       filename,
       fileid,
       filegroup,
       ( totalextents * 64 )                        filesize_kb,
       usedextents * 64                             usedsize_kb,
       ( totalextents * 64 ) - ( usedextents * 64 ) freespace_kb
FROM   freefilespace


No comments:

Post a Comment

Amazon Contextual Product Ads

Popular Posts