mirror of
https://github.com/acedanger/budget-database.git
synced 2025-12-05 22:50:13 -08:00
23 lines
518 B
Transact-SQL
23 lines
518 B
Transact-SQL
use Leo
|
|
go
|
|
|
|
alter proc dbo.proc_UpdateHolidaysTable
|
|
as
|
|
if not exists(select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'HOLIDAYS')
|
|
create table dbo.HOLIDAYS(dt date primary key clustered, Holiday varchar(50))
|
|
|
|
declare @year int = 2019
|
|
|
|
while @year < year(getdate()) + 40
|
|
begin
|
|
insert into dbo.Holidays(dt, Holiday)
|
|
select fhol.dt, fhol.Holiday
|
|
from
|
|
dbo.tvf_GetHolidays(@year) fhol
|
|
left join dbo.Holidays tbh on fhol.dt = tbh.dt
|
|
where fhol.dt is null
|
|
|
|
set @year = @year + 1
|
|
end
|
|
go
|