A SQL Query to find database files

 1 SELECT
 2 DB_NAME(mf.database_id) AS databaseName,
 3 name as File_LogicalName,
 4 case
 5 when type_desc = LOG then Log File
 6 when type_desc = ROWS then Data File
 7 Else type_desc
 8 end as File_type_desc
 9 ,mf.physical_name
10 ,num_of_reads
11 ,num_of_bytes_read
12 ,io_stall_read_ms
13 ,num_of_writes
14 ,num_of_bytes_written
15 ,io_stall_write_ms
16 ,io_stall
17 ,size_on_disk_bytes
18 ,size_on_disk_bytes/ 1024 as size_on_disk_KB
19 ,size_on_disk_bytes/ 1024 / 1024 as size_on_disk_MB
20 ,size_on_disk_bytes/ 1024 / 1024 / 1024 as size_on_disk_GB
21 FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS divfs
22 JOIN sys.master_files AS mf ON mf.database_id = divfs.database_id
23 AND mf.file_id = divfs.file_id
24 ORDER BY size_on_disk_MB DESC

 

A SQL Query to find database files,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。