Wenn man im SQL Server 2005 wissen will, was so alles im Datencache steht, dann kann man sich mit Hilfe der Data Management View "sys.dm_os_buffer_descriptors" einen Überblick verschaffen. Man erfährt welche Seite in den Cache geladen wurden.

Mit diesem Statement sieht man sogar wie viele Seiten aktuell von welcher Tabelle aus welcher Datenbank im Cache "belegt" werden:

SELECT CASE GROUPING(db.name) WHEN 0 THEN db.name ELSE N'#all dbs#' END AS [dbname],
CASE GROUPING(object_name(p.object_id)) WHEN 0 THEN object_name(p.object_id) ELSE N'#all objects#' END AS [objname],
CASE GROUPING(p.index_id) WHEN 0 THEN CAST(p.index_id AS NVARCHAR) ELSE N'#all indexes#' END AS [indexid],
COUNT(page_id) AS [pagecount]
FROM sys.dm_os_buffer_descriptors AS bd
JOIN sys.allocation_units AS au
ON bd.allocation_unit_id = au.allocation_unit_id
JOIN sys.partitions p
ON au.container_id = p.hobt_id
JOIN sys.databases as db
ON bd.database_id = db.database_id
GROUP BY db.name, object_name(p.object_id), p.index_id WITH ROLLUP
ORDER BY [pagecount] DESC

Ich hoffe das hilft jemandem… 😉