/ Published in: SQL
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
WITH g AS ( SELECT DB_NAME(mf.database_id) AS database_name, mf.physical_name, LEFT(mf.physical_name, 1) AS drive_letter, vfs.num_of_writes, vfs.num_of_bytes_written/1048576 AS MBwritten, vfs.io_stall_write_ms, mf.type_desc, vfs.num_of_reads, vfs.num_of_bytes_read, vfs.io_stall_read_ms, vfs.io_stall, vfs.size_on_disk_bytes FROM sys.master_files mf JOIN sys.dm_io_virtual_file_stats(NULL, NULL) vfs ON mf.database_id=vfs.database_id AND mf.file_id=vfs.file_id -- order by vfs.num_of_bytes_written desc) ) SELECT database_name, drive_letter, MBwritten, percentage=RTRIM(CONVERT(DECIMAL(5,2), MBwritten*100.0/(SELECT SUM(MBwritten) FROM g))) --- where drive_letter='R'))) + '%', io_stall_read_ms, io_stall_write_ms FROM g -- where drive_letter='R' ORDER BY MBwritten DESC