Getting space used from mdf

  • What is the t-sql syntax for getting the actual space used in an mdf?

  • Try this...

    SELECT D.name,

    CAST(CAST((D.SIZE * 8 / 1024.0) AS DECIMAL(18,2)) AS VARCHAR(20)) FILESIZE_MB,

    CAST((D.SIZE * 8 / 1024.0) - (fileproperty(Name,'SpaceUsed') / 128.0) AS DECIMAL(15,2)) SPACEFREE_MB

    FROM sysfiles D

  • That's it. Thanks.

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

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