Hi Folks,
In this article we are going to cover How to List all Objects and Indexes per Filegroup or Partition.
In this post we are going to discuss following points:
- Problem Statement of SQL Script:
- Description of SQL Script:
- SQL Script Output Column
- SQL Script Code
- SQL Script Output Screenshot
- User Level to execute
Problem Statement of SQL Script:
Find List of all Objects and Indexes per Filegroup or Partition.
Description of SQL Script:
Transact-SQL statement using Dynamic Management Views to list all Objects and Indexes per Filegroup / Partition and Allocation Type including the allocated data size of the actual database. Additional several meta data of the objects are selected to give overview information of the data size usage.
SQL Script Output Column
SQL Script Code
SELECT DS.NAME AS DataSpaceName ,AU.type_desc AS AllocationDesc ,AU.total_pages / 128 AS TotalSizeMB ,AU.used_pages / 128 AS UsedSizeMB ,AU.data_pages / 128 AS DataSizeMB ,SCH.NAME AS SchemaName ,OBJ.type_desc AS ObjectType ,OBJ.NAME AS ObjectName ,IDX.type_desc AS IndexType ,IDX.NAME AS IndexName FROM sys.data_spaces AS DS INNER JOIN sys.allocation_units AS AU ON DS.data_space_id = AU. data_space_id INNER JOIN sys.partitions AS PA ON ( AU.type IN ( 1 ,3 ) AND AU.container_id = PA.hobt_id ) OR ( AU.type = 2 AND AU.container_id = PA.partition_id ) INNER JOIN sys.objects AS OBJ ON PA.object_id = OBJ.object_id INNER JOIN sys.schemas AS SCH ON OBJ.schema_id = SCH.schema_id LEFT JOIN sys.indexes AS IDX ON PA.object_id = IDX.object_id AND PA.index_id = IDX.index_id ORDER BY DS.NAME ,SCH.NAME ,OBJ.NAME ,IDX.NAME
SQL Script Output Screenshot
User Level to execute
- 200
Hope you will like How to List all Objects and Indexes per Filegroup or Partition.
If you really like reading my blog and understood at least few thing then please don’t forget to subscribe my blog.
If you want daily link and analysis or interesting link go to following website which will give @ your inbox please subscribe our following link resource blog :
For More information related to BI World visit my Mentalist Blog
SQL Server Mentalist >> SQL Learning Blog
Business Intelligence Mentalist >> BI World
Infographic Mentalist >> Image worth explaining thousand Words
Microsoft Mentalist >> MVC,ASP.NET, WCF & LinQ
DBA Mentalist >>Advance SQL Server Blog
Microsoft BI Mentalist >> MS BI Development Update
Connect With me on
Filed under: Link, Microsoft SQL Server, MSBI, Optimization, Query, Script, SQL Mentalist, SQL PraRup, SQL Query, SQL Server, Technology,, TSQL, Vishal Pawar Tagged: DBA, Fast SQL, Microsoft SQL Server, SQL Help, SQL Mentalist, SQL Script, SQL Server, SQL Server 2008 R2, SQL Server 2012, SQL tips, SQL Tricks, TSQL, Vishal Pawar
