생성11

발행: (2025년 12월 4일 오전 06:44 GMT+9)
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에서 지난 45일간 추가된 행 수를 세는 T-SQL 스크립트

비교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...