Most Used Database Files in SQL Server

Hello everyone,

In this article, I will try to give information about finding the most used database files in SQL Server.

In SQL Server, in some cases you may want to find the most used database files.

You can easily do this by using the script below.

SELECT DB_NAME(DbId) 'Database Name',
       physical_name 'File Location',
       NumberReads 'Number of Reads',
       BytesRead 'Bytes Read',
       NumberWrites 'Number of Writes',
       BytesWritten 'Bytes Written',
       IoStallReadMS 'IO Stall Read',
       IoStallWriteMS 'IO Stall Write',
       IoStallMS AS 'Total IO Stall (ms)'
FROM fn_virtualfilestats(NULL, NULL) fs
    INNER JOIN sys.master_files mf
        ON fs.DbId = mf.database_id
           AND fs.FileId = mf.file_id

When you run the script, you will see a result similar to the one below.

Most Used Database Files in SQL Server

As you can see, the most used database files are listed.

Good luck to everyone in business and life.


Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!