Forum Discussion
Keep Previous RowCounts in a table - T-SQL
I am currently able to get the rowcount for each table in a schema. On this particular database history is not stored, so each day when I run this script, the counts are likely to differ. What I need to do is somehow keep a record of what the counts for each table were on previous dates. Is there a way I can do this using T-SQL - I can't seem to figure out how to approach this. Also CDC is disabled - so I am limited to having to script a solution using T-SQL. The table I get daily simply lists schema, tablename and rowcount - rowcount is realtime. I would like to keep previous counts associated with a date so result will produce a table with - schema, tablename RowCount_19May, RowCount_18May, RowCount_17May, ... , RowCount_1May. Even if i need to start today and the append each new days counts as the days go by is expected and I'd be good with that.