DB Sizes

  • How can i get list of databases thata are older than 3 years and size of each db.

    thanks

  • Try this:

    use master;

    go

    select

    db.[name] as 'Database Name'

    ,db.crdate

    ,(((CAST(af. as DECIMAL(18,4)) * 8192) /1024) /1024) as 'File Size (MB)'

    from sys.sysdatabases db

    inner join sys.sysaltfiles af

    on db.dbid = af.dbid

    where [fileid] in (1) and db.crdate < dateadd(year,-3,getdate());

  • I assume you mean created 3 years ago or earlier. Lee's code should do that.

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

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