• Thank you everyone for coming to the rescue! There's just so much to juggle during the holiday season that, inevitably, something falls to the ground. This year it just happened to be my T-SQL.

    The code by Luis, Sean and Scott did the trick. I had to modify it slightly by adding the WHERE filter, like:

    SELECT @SQL = @SQL + 'insert #Temp SELECT ''' + TABLE_NAME + ''' as TableName,

    DATEADD( dd, DATEDIFF( dd, 0, _when), 0) as LastUpdate,

    COUNT(*) as RecordCount

    FROM [' + TABLE_SCHEMA + '].[' + TABLE_NAME + ']

    GROUP BY DATEADD( dd, DATEDIFF( dd, 0, _when), 0);'

    FROM INFORMATION_SCHEMA.tables

    WHERE table_type = 'base table'

    because I didn't want views.

    J.Faehrmann mentioned the sp_msforeachtable procedure. Very interesting.

    Have a great holiday everyone!

    John