创建11

发布: (2025年12月4日 GMT+8 05:44)
1 min read
原文: Dev.to

Source: Dev.to

SQL 脚本

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)
Back to Blog

相关文章

阅读更多 »

创建12

用于DBVisualizer的T-SQL脚本,统计过去45天内添加的行数

比较5

SQL Script sql -- 声明用于模式 UID 的变量,仅运行一次 DECLARE @uid1 int, @uid2 int SELECT @uid1 = uid FROM sysusers WHERE name = 'GLOBAL_COMET_US_1' SEL...

比较4

sql -- 首先获取用户ID(可选),以提高可读性 DECLARE @uid1 int, @uid2 int SELECT @uid1 = uid FROM sysusers WHERE name = 'GLOBAL_COMET_US_1' SELE...