set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER 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