Using the following query I can get the size of the indexes for a table:
SELECT i.name AS IndexName, SUM(page_count * 8) AS IndexSizeKB FROM sys.dm_db_index_physical_stats(db_id(), object_id('schema.table'), NULL, NULL, 'DETAILED') AS s JOIN sys.indexes AS i ON s.[object_id] = i.[object_id] AND s.index_id = i.index_id GROUP BY i.name ORDER BY i.name
If I execute
sp_spaceused 'schema.table' does the size without indexes correspond to
Any way to get the size of the table without indexes in sql server? (
SELECT statement would be nice as I'd like to plug this query into a bigger query).
If I execute Get size of all tables in database, the sizes for tables are almost the same as the sizes for indexes (suggesting that something is wrong).