Technical Article

Find Size of files used in Database

,

This script provides File Size, Space Used and Free Space avaialable for each file like Main file, Log file and each partition file in a database.

Below is the screenshot which I see in a database having 12 partitions, 1 each of every Month.

script results

SELECT
      Name
    , Filename
    , convert(decimal(12,2),round(size/128.000,2)) as FileSizeMB
    , convert(decimal(12,2),round(fileproperty(name,'SpaceUsed')/128.000,2)) as SpaceUsedMB
    , convert(decimal(12,2),round((size-fileproperty(name,'SpaceUsed'))/128.000,2)) as FreeSpaceMB
FROM dbo.sysfiles

Rate

3.33 (3)

You rated this post out of 5. Change rating

Share

Share

Rate

3.33 (3)

You rated this post out of 5. Change rating