• To expand on ianhenderson's way here is the loop without worrying about the lowest id and just grabbing the next one that doesn't have a count.

    DECLARE @TableName VARCHAR(255);

    SELECT TABLE_NAME AS TableName, null AS RowCnt

    INTO #TempTableCounts

    FROM INFORMATION_SCHEMA.TABLES

    WHERE TABLE_TYPE = 'base table';

    WHILE (EXISTS(SELECT * FROM #TempTableCounts WHERE (RowCnt IS NULL))) BEGIN

    SELECT TOP(1) @TableName = TableName FROM #tempTableCounts WHERE (RowCnt IS NULL);

    EXEC ('UPDATE #TempTableCounts SET RowCnt = (SELECT count(*) FROM ' + @TableName + ') WHERE (TableName = ''' + @TableName + ''')');

    END

    SELECT TableName, RowCnt FROM #TempTableCounts;

    DROP TABLE #TempTableCounts;

    -David