I've been looking for several days to find a way of finding the table sizes for every database within the current SQL instance. Currently im able to get the tables sizes for the current database without issue using sp_spaceused, is there a way of using sp_MSforeachdb to get the size information?
I can list all the tables but not sure how you would add the table sizes.
Declare @temp_table table
(
DB_NAME varchar(max),
TABLE_OWNER varchar(max),
TABLE_NAME varchar(max),
TABLE_TYPE varchar(max),
REMARKS varchar(max)
)
INSERT INTO @temp_table (DB_NAME, TABLE_OWNER, TABLE_NAME, TABLE_TYPE,REMARKS)
EXECUTE master.sys.sp_MSforeachdb 'USE [?]; EXEC sp_tables'
SELECT DB_NAME, TABLE_OWNER, TABLE_NAME, TABLE_TYPE
FROM @temp_table
WHERE DB_NAME not in ('master','model','msdb','tempdb') and [TABLE_TYPE] = 'TABLE'
order by 1,2,3
Any advice would be welcomed.
Thanks in advance..