Return to Snippet

Revision: 25399
at March 30, 2010 06:44 by tvanzele


Initial Code
With Agg_IO_Stats
AS
(
	select 
		DB_NAME(database_id) AS database_name,
		CAST(sum(num_of_bytes_read + num_of_bytes_written) / 1048576 as decimal(12,2)) as io_in_mb
	from sys.dm_io_virtual_file_stats(NULL, NULL) as DM_IO_Stats
	group by database_id
)
select
	ROW_NUMBER() over(order by io_in_mb DESC) as row_num,
	database_name,
	io_in_mb,
	CAST(io_in_mb / SUM(io_in_mb) over() * 100 as decimal(5,2)) as pct
FROM Agg_IO_Stats
order by row_num;

Initial URL

                                

Initial Description

                                

Initial Title
Percentage of IO for each database

Initial Tags
sql

Initial Language
SQL