Archive for October, 2011

To count all database updates for all tables (that containe a datetime field), just execute this query:

— purpose – see if this database is being updated
— use a set of queries on datetime fields.
— Make the queries dynamic, and pass in the table and column names.
— collate results into a temp table and then display all together
declare @t_name varchar(50)
declare @c_name varchar(50)
declare @query_base varchar(250)
set @query_base = ‘select {QQQTABLE} as [TableName], count(*) as CountRecentUpdates from QQQTABLE where QQQCOLUMN > dateadd(d,-1,getdate() )’
declare @query varchar(500)
declare @TempTableInsert varchar(80)
set @TempTableInsert = ‘ insert into #MyTempTable ([TableName] , [CountRecentUpdates] ) ‘