• HanShi (11/25/2016)


    Use the queries below to get the desired information.

    Execute it at regular intervals (daily?) and store the results. Build a reporting query on these stored results to get the differences in size over time.

    SELECT Db_name(database_id) AS database_name

    , NAME AS file_name

    , type_desc

    , Cast(size * 8.0 / 1024 AS DECIMAL(10, 2)) AS size_MB

    , Cast(max_size * 8.0 / 1024 AS DECIMAL(10, 2)) AS max_size_MB

    , GetDate() as inquiry_date

    FROM sys.master_files;

    SELECT database_name

    , backup_size

    , compressed_backup_size

    , GetDate() as inquiry_date

    FROM msdb..backupset;

    Just a bit of a simplification...

    SELECT Db_name(database_id) AS database_name

    , NAME AS file_name

    , type_desc

    , Cast(size / 128.0 AS DECIMAL(10, 2)) AS size_MB

    , Cast(max_size / 128.0 AS DECIMAL(10, 2)) AS max_size_MB

    , GetDate() as inquiry_date

    FROM sys.master_files;

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)