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
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