Search This Blog

SQL Server Memory used by a database

The query will let you know the database list of the instance and the memory in MB used by the databases.
SELECT 
    database_id AS DatabaseID,  
    DB_NAME(database_id) AS DatabaseName,  
    COUNT(file_id) * 8/1024.0 AS BufferSizeInMB  
FROM 
    sys.dm_os_buffer_descriptors  
GROUP BY DB_NAME(database_id),database_id  
ORDER BY BufferSizeInMB DESC



















The example picture shows the database name and its BufferSizeInMB, this information can helpful while investigating the database performance issue to know how much the memory is used by the database.