Hi Experts, Is there is powershell script which displays top 10 database tables taking up more space in each database on that sql instance in a nice HTML table format. I am not an powershell expert and so seeking for help. Checking if someone can help on this. Also, if we can execute it against multiple sql instance it will be even more usefull. Actual requirement.Here is my base query and this has to be executed against all databases across multiple servers and send me an email in an HTML format.SELECT DISTINCT TOP 10 DB_NAME() AS DatabaseName ,s.Name AS SchemaName ,object_name(i.object_id) AS TableName , i.index_id AS IndexID , i.type_desc AS IndexType ,p.data_compression_desc , p.[rows] AS NumRows , CAST((au.total_pages * 8/1024.) AS numeric(15,2)) AS [TotalSize MB] , CAST((au.total_pages * 8/(1024.*1024)) AS numeric(15,2)) AS [TotalSize GB] FROM sys.indexes i INNER JOIN sys.partitions p ON i.object_id = p.object_id AND i.index_id = p.index_id INNER JOIN sys.tables t ON t.OBJECT_ID = i.object_id INNER JOIN sys.allocation_units au ON CASE WHEN au.[type] in (1,3) THEN p.hobt_id WHEN au.type = 2 THEN p.partition_id end = au.container_id INNER JOIN sys.objects o ON i.object_id = o.object_id INNER JOIN sys.filegroups f ON i.data_space_id = f.data_space_id INNER JOIN [sys].[database_files] d ON f.[data_space_id] = d.[data_space_id] LEFT OUTER JOIN sys.schemas s ON t.schema_id = s.schema_id Where t.type_desc ='USER_TABLE' and i.index_id in (0,1) --- 0 -- heaps tbls , 1 -- clustered indexes and au.total_pages > 0 and o.is_ms_shipped <> 1 ORDER BY [TotalSize MB] DESCThanks in advance. Sam
↧