Hi,
(SQL 2008R2 - enterprise)
Looking for a way of calculating table cardinality for all databases in an instance. Is there a way of adapting this code to run against all databases?
DECLARE @TableRowCounts TABLE ([TableName] VARCHAR(128), [RowCount] INT) ; INSERT INTO @TableRowCounts ([TableName], [RowCount]) EXEC sp_MSforeachtable 'SELECT ''?'' [TableName], COUNT(*) [RowCount] FROM ?' ; SELECT [TableName], [RowCount] FROM @TableRowCounts ORDER BY [TableName]
I'm looking to run this job on a Sunday so I can see the actual cardinality as the estimated is way out.
Thanks