
Get All the Tables with a Count of Their Records
Get all the tables with a count of their records with the following query: CREATE TABLE #Temp ( TableName VARCHAR(MAX), Rows INT ); EXEC sp_MSForEachTable @command1 = ‘INSERT INTO #Temp(TableName, Rows) SELECT ”?”, COUNT(*) FROM ?’ SELECT * FROM #Temp ORDER BY Temp.Rows DESC; DROP TABLE #Temp;