All pastes #285358 Raw Edit

MtDew

public sql v1 · immutable
#285358 ·published 2006-12-19 20:03 UTC
rendered paste body
set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoALTER procedure [sys].[sp_databases]as    set nocount on    select        DATABASE_NAME   = db_name(s_mf.database_id),        DATABASE_SIZE   = convert(int,                                    case -- more than 2TB(maxint) worth of pages (by 8K each) can not fit an int...                                    when convert(bigint, sum(s_mf.size)) >= 268435456                                    then null                                    else sum(s_mf.size)*8 -- Convert from 8192 byte pages to Kb                                    end),         REMARKS         = convert(varchar(254),null)    from        sys.master_files s_mf    where        s_mf.state = 0 and -- ONLINE        has_dbaccess(db_name(s_mf.database_id)) = 1 -- Only look at databases to which we have access    group by s_mf.database_id    order by 1