Monday, April 2, 2012

SQL Server 2000 file size details


Find File name, file size in MB, used space in MB and free space in MB for SQL Server 2000 database by changing the database name


use <dbname>
go
select
      name
    , filename
    , convert(decimal(12,2),round(a.size/128.000,2)) as FileSizeMB
    , convert(decimal(12,2),round(fileproperty(a.name,'SpaceUsed')/128.000,2)) as SpaceUsedMB
    , convert(decimal(12,2),round((a.size-fileproperty(a.name,'SpaceUsed'))/128.000,2)) as FreeSpaceMB
from dbo.sysfiles a


No comments:

Post a Comment