A SQL Query to find database files

Source: Internet
Author: User

1 SELECT2 db_name(mf.database_id) asDatabaseName,3Name asFile_logicalname,4  Case5  whenType_desc= 'LOG'  Then 'Log File'6  whenType_desc= 'ROWS'  Then 'Data File'7 ElseType_desc8 End  asFile_type_desc9 , Mf.physical_nameTen , Num_of_reads One , Num_of_bytes_read A , Io_stall_read_ms - , Num_of_writes - , Num_of_bytes_written the , Io_stall_write_ms - , Io_stall - , Size_on_disk_bytes -, size_on_disk_bytes/ 1024x768  assize_on_disk_kb +, size_on_disk_bytes/ 1024x768 / 1024x768  asSIZE_ON_DISK_MB -, size_on_disk_bytes/ 1024x768 / 1024x768 / 1024x768  asSIZE_ON_DISK_GB +  fromSys.dm_io_virtual_file_stats (NULL,NULL) asDivfs A JOINSys.master_files asMf onmf.database_id=divfs.database_id at  andMf.file_id =Divfs.file_id - ORDER  bySize_on_disk_mbDESC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.