CREATE TABLE #temp (TableName VARCHAR (255), RowCnt INT)EXEC sp_MSforeachtable 'INSERT INTO #temp SELECT ''?'', COUNT(*) FROM ?'SELECT TableName, RowCnt FROM #temp ORDER BY RowCntDROP TABLE #temp;