DEV Community

Query Filter
Query Filter

Posted on

create11

declare @sql varchar(8000)
select @sql = ''
select @sql = @sql + 'select "'+name+'" , count(*) from '+name+
              ' where INTERNTIMESTAMP >= dateadd(dd,-45,getdate()) union all '
from sysobjects where type='U' 
  and exists (select 1 from syscolumns c where c.id=object_id(name) and c.name='INTERNTIMESTAMP')
order by name

-- remove the trailing ' union all '
select @sql = substring(@sql,1,len(@sql)-11)  
exec(@sql)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)