select
(count(*) * 8) / 1024 as [MB Used],
object_schema_name( obj.[object_id] ) [Schema Name],
obj.[name] [tablename],
obj.[index_id]
from sys.dm_os_buffer_descriptors bd
join (
select
object_name( p.[object_id] ) [name],
p.[index_id],
au.[allocation_unit_id],
p.[object_id]
from sys.allocation_units au
join sys.partitions p on ( au.[container_id] = p.[hobt_id] and ( au.[type] = 1 or au.[type] = 3 ) )
or ( au.[container_id] = p.[partition_id] and au.[type] = 2 )
) obj on bd.[allocation_unit_id] = obj.[allocation_unit_id]
where bd.[database_id] = db_id()
group by object_schema_name( obj.[object_id] ), [name], [index_id]
order by [MB Used] desc
Like this:
Like Loading...
Related
Published by Protiguous
C# Software Developer, SQL Server DBA, Father, and seeker of Truth.
View all posts by Protiguous