set nocount on
go
declare @sql varchar(16384)
select @sql = ''
select @sql = @sql +
'select ''' + o.name + ''' as table_name, ' +
'count(*) as recent_rows ' +
'from ' + db_name() + '..' + o.name +
' where INTERNTIMESTAMP >= dateadd(day, -45, getdate()) ' +
'having count(*) > 0 union all '
from sysobjects o
where o.type = 'U'
and exists (select 1 from syscolumns c where c.id = o.id and c.name = 'INTERNTIMESTAMP')
order by o.name
/* Remove trailing ' union all ' */
if len(@sql) >= 11
select @sql = left(@sql, len(@sql) - 11)
else
select @sql = 'select ''No recent data found'' as table_name, 0 as recent_rows'
/* Execute and show results */
exec (@sql)
go
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)