查看每个数据库对内存的占用
SELECT ISNULL(DB_NAME(DATABASE_ID),'RESOURCEDB') AS DATABASENAME, CAST(COUNT(ROW_COUNT) * 8.0 /(1024.0) AS DECIMAL(28,2)) AS 'SIZE(MB)' FROM SYS.dm_os_buffer_descriptors GROUP BY database_id ORDER BY DATABASENAME
整个sql服务占用的总内存
SELECT SUM(single_pages_kb)+SUM(MULTI_PAGES_KB) FROM ( SELECT SUM(single_pages_kb) AS single_pages_kb ,SUM(MULTI_PAGES_KB) AS MULTI_PAGES_KB FROM SYS.dm_os_memory_clerks GROUP BY [TYPE]
) AS A UNION SELECT COUNT(ROW_COUNT) * 8.0 FROM SYS.dm_os_buffer_descriptors
内容转载自: https://www.cnblogs.com/jearay/p/7825499.html