Monday, January 24, 2011

Script to calculate DB size and available size


SELECT Db_name()                                                           AS
       dbname,
       name                                                                AS
       filename,
       size / 128.0                                                        AS
       currentsizemb,
       size / 128.0 - CAST(Fileproperty(name, 'SpaceUsed') AS INT) / 128.0 AS
       freespacemb
FROM   sys.database_files; 

No comments:

Post a Comment