USE [EnVisage]
GO

update  Holiday set Options= (select
'{"periodOption":"4","dailyOption":"2","dailyDay":"2","weeklyWeeks":"","monthlyOption":"1","monthlyDate":"2","monthlyMonths":"3","monthlyOccurrence":"SameDayEveryYear","monthlyWeek":"Monday","monthlyMonth":"",
"yearlyOption":"1","yearlyYear":"1","yearlyMonth":"'+ convert( varchar(4), OccurrenceMonth) +'","yearlyMonthNumber":"'+ convert( varchar(4), OccurrenceMonthDay) +
'","yearlyOccurrence":"SameDayEveryYear","yearlyWeek":"Monday","yearlyMonth2":"1","range_start_picker":"'+(convert( varchar(4), DATEPART(MONTH, CreatedAt) ) +'/'+convert( varchar(4), DATEPART(DAY, CreatedAt))+'/'+convert( varchar(4), DATEPART(YEAR, CreatedAt)))+'","rangeOption":"1","Occurrences":"","range_picker":""}'
from Holiday h where h.Id =Holiday.Id) where OccurrenceType = 0 --SameDayEveryYear = 0

update  Holiday set Options= (select
'{"periodOption":"4","dailyOption":"2","dailyDay":"2","weeklyWeeks":"","monthlyOption":"1","monthlyDate":"2","monthlyMonths":"3","monthlyOccurrence":"SameDayEveryYear","monthlyWeek":"Monday","monthlyMonth":"",
"yearlyOption":"1","yearlyYear":"1","yearlyMonth":"'+ convert( varchar(4), OccurrenceMonth) +'","yearlyMonthNumber":"'+ convert( varchar(4), OccurrenceMonthDay) +
'","yearlyOccurrence":"SameDayEveryYear","yearlyWeek":"Monday","yearlyMonth2":"1","range_start_picker":"'+(convert( varchar(4), DATEPART(MONTH, CreatedAt) ) +'/'+convert( varchar(4), DATEPART(DAY, CreatedAt))+'/'+convert( varchar(4), DATEPART(YEAR, CreatedAt)))+'","rangeOption":"2","Occurrences":"1","range_picker":""}'
from Holiday h where h.Id =Holiday.Id) where OccurrenceType = 7 --OnlyOnce = 7


update  Holiday set Options= (select
'{"periodOption":"4","dailyOption":"2","dailyDay":"2","weeklyWeeks":"","monthlyOption":"1","monthlyDate":"2","monthlyMonths":"3",
"monthlyOccurrence":"SameDayEveryYear","monthlyWeek":"Monday","monthlyMonth":"",
"yearlyOption":"2","yearlyYear":"1","yearlyMonth":"'+ convert( varchar(4), OccurrenceMonth) +'","yearlyMonthNumber":"'+ convert( varchar(4), OccurrenceMonthDay) +
'","yearlyOccurrence":"FirstDayOfWeek","yearlyWeek":"'
+(case when OccurrenceWeekDay = 1 then 'Monday' 
when OccurrenceWeekDay = 2 then 'Tuesday' 
when OccurrenceWeekDay = 3 then 'Wednesday' 
when OccurrenceWeekDay = 4 then 'Thursday' 
when OccurrenceWeekDay = 5 then 'Friday' 
when OccurrenceWeekDay = 6 then 'Saturday' 
when OccurrenceWeekDay = 0 then 'Sunday'  end)+
'","yearlyMonth2":"'+ convert( varchar(4), OccurrenceMonth) +'","range_start_picker":"'+(convert( varchar(4), DATEPART(MONTH, CreatedAt) ) +'/'+convert( varchar(4), DATEPART(DAY, CreatedAt))+'/'+convert( varchar(4), DATEPART(YEAR, CreatedAt)))+'","rangeOption":"1","Occurrences":"","range_picker":""}'
from Holiday h where h.Id =Holiday.Id) where OccurrenceType = 1 --FirstDayOfWeek = 1
     
update  Holiday set Options= (select
'{"periodOption":"4","dailyOption":"2","dailyDay":"2","weeklyWeeks":"","monthlyOption":"1","monthlyDate":"2","monthlyMonths":"3",
"monthlyOccurrence":"SecondDayOfWeek","monthlyWeek":"Monday","monthlyMonth":"",
"yearlyOption":"2","yearlyYear":"1","yearlyMonth":"'+ convert( varchar(4), OccurrenceMonth) +'","yearlyMonthNumber":"'+ convert( varchar(4), OccurrenceMonthDay) +
'","yearlyOccurrence":"FirstDayOfWeek","yearlyWeek":"'
+(case when OccurrenceWeekDay = 1 then 'Monday' 
when OccurrenceWeekDay = 2 then 'Tuesday' 
when OccurrenceWeekDay = 3 then 'Wednesday' 
when OccurrenceWeekDay = 4 then 'Thursday' 
when OccurrenceWeekDay = 5 then 'Friday' 
when OccurrenceWeekDay = 6 then 'Saturday' 
when OccurrenceWeekDay = 0 then 'Sunday'  end)+
'","yearlyMonth2":"'+ convert( varchar(4), OccurrenceMonth) +'","range_start_picker":"'+(convert( varchar(4), DATEPART(MONTH, CreatedAt) ) +'/'+convert( varchar(4), DATEPART(DAY, CreatedAt))+'/'+convert( varchar(4), DATEPART(YEAR, CreatedAt)))+'","rangeOption":"1","Occurrences":"","range_picker":""}'
from Holiday h where h.Id =Holiday.Id) where OccurrenceType = 2 --SecondDayOfWeek = 2

update  Holiday set Options= (select
'{"periodOption":"4","dailyOption":"2","dailyDay":"2","weeklyWeeks":"","monthlyOption":"1","monthlyDate":"2","monthlyMonths":"3",
"monthlyOccurrence":"ThirdDayOfWeek","monthlyWeek":"Monday","monthlyMonth":"",
"yearlyOption":"2","yearlyYear":"1","yearlyMonth":"'+ convert( varchar(4), OccurrenceMonth) +'","yearlyMonthNumber":"'+ convert( varchar(4), OccurrenceMonthDay) +
'","yearlyOccurrence":"FirstDayOfWeek","yearlyWeek":"'
+(case when OccurrenceWeekDay = 1 then 'Monday' 
when OccurrenceWeekDay = 2 then 'Tuesday' 
when OccurrenceWeekDay = 3 then 'Wednesday' 
when OccurrenceWeekDay = 4 then 'Thursday' 
when OccurrenceWeekDay = 5 then 'Friday' 
when OccurrenceWeekDay = 6 then 'Saturday' 
when OccurrenceWeekDay = 0 then 'Sunday'  end)+
'","yearlyMonth2":"'+ convert( varchar(4), OccurrenceMonth) +'","range_start_picker":"'+(convert( varchar(4), DATEPART(MONTH, CreatedAt) ) +'/'+convert( varchar(4), DATEPART(DAY, CreatedAt))+'/'+convert( varchar(4), DATEPART(YEAR, CreatedAt)))+'","rangeOption":"1","Occurrences":"","range_picker":""}'
from Holiday h where h.Id =Holiday.Id) where OccurrenceType = 3 --ThirdDayOfWeek = 3

update  Holiday set Options= (select
'{"periodOption":"4","dailyOption":"2","dailyDay":"2","weeklyWeeks":"","monthlyOption":"1","monthlyDate":"2","monthlyMonths":"3",
"monthlyOccurrence":"FourthDayOfWeek","monthlyWeek":"Monday","monthlyMonth":"",
"yearlyOption":"2","yearlyYear":"1","yearlyMonth":"'+ convert( varchar(4), OccurrenceMonth) +'","yearlyMonthNumber":"'+ convert( varchar(4), OccurrenceMonthDay) +
'","yearlyOccurrence":"FirstDayOfWeek","yearlyWeek":"'
+(case when OccurrenceWeekDay = 1 then 'Monday' 
when OccurrenceWeekDay = 2 then 'Tuesday' 
when OccurrenceWeekDay = 3 then 'Wednesday' 
when OccurrenceWeekDay = 4 then 'Thursday' 
when OccurrenceWeekDay = 5 then 'Friday' 
when OccurrenceWeekDay = 6 then 'Saturday' 
when OccurrenceWeekDay = 0 then 'Sunday'  end)+
'","yearlyMonth2":"'+ convert( varchar(4), OccurrenceMonth) +'","range_start_picker":"'+(convert( varchar(4), DATEPART(MONTH, CreatedAt) ) +'/'+convert( varchar(4), DATEPART(DAY, CreatedAt))+'/'+convert( varchar(4), DATEPART(YEAR, CreatedAt)))+'","rangeOption":"1","Occurrences":"","range_picker":""}'
from Holiday h where h.Id =Holiday.Id) where OccurrenceType = 4 --FourthDayOfWeek = 4

update  Holiday set Options= (select
'{"periodOption":"4","dailyOption":"2","dailyDay":"2","weeklyWeeks":"","monthlyOption":"1","monthlyDate":"2","monthlyMonths":"3",
"monthlyOccurrence":"LastDayOfWeek","monthlyWeek":"Monday","monthlyMonth":"",
"yearlyOption":"2","yearlyYear":"1","yearlyMonth":"'+ convert( varchar(4), OccurrenceMonth) +'","yearlyMonthNumber":"'+ convert( varchar(4), OccurrenceMonthDay) +
'","yearlyOccurrence":"FirstDayOfWeek","yearlyWeek":"'
+(case when OccurrenceWeekDay = 1 then 'Monday' 
when OccurrenceWeekDay = 2 then 'Tuesday' 
when OccurrenceWeekDay = 3 then 'Wednesday' 
when OccurrenceWeekDay = 4 then 'Thursday' 
when OccurrenceWeekDay = 5 then 'Friday' 
when OccurrenceWeekDay = 6 then 'Saturday' 
when OccurrenceWeekDay = 0 then 'Sunday'  end)+
'","yearlyMonth2":"'+ convert( varchar(4), OccurrenceMonth) +'","range_start_picker":"'+(convert( varchar(4), DATEPART(MONTH, CreatedAt) ) +'/'+convert( varchar(4), DATEPART(DAY, CreatedAt))+'/'+convert( varchar(4), DATEPART(YEAR, CreatedAt)))+'","rangeOption":"1","Occurrences":"","range_picker":""}'
from Holiday h where h.Id =Holiday.Id) where OccurrenceType = 5 --LastDayOfWeek = 5

update  Holiday set Options= (select
'{"periodOption":"4","dailyOption":"2","dailyDay":"2","weeklyWeeks":"","monthlyOption":"1","monthlyDate":"2","monthlyMonths":"3","monthlyOccurrence":"SameDayEveryYear","monthlyWeek":"Monday","monthlyMonth":"",
"yearlyOption":"2","yearlyYear":"1","yearlyMonth":"'+ convert( varchar(4), OccurrenceMonth) +'","yearlyMonthNumber":"'+ convert( varchar(4), OccurrenceMonthDay) +
'","yearlyOccurrence":"FirstDayOfWeek","yearlyWeek":"'
+(case when OccurrenceWeekDay = 1 then 'Monday' 
when OccurrenceWeekDay = 2 then 'Tuesday' 
when OccurrenceWeekDay = 3 then 'Wednesday' 
when OccurrenceWeekDay = 4 then 'Thursday' 
when OccurrenceWeekDay = 5 then 'Friday' 
when OccurrenceWeekDay = 6 then 'Saturday' 
when OccurrenceWeekDay = 0 then 'Sunday'  end)+
'","yearlyMonth2":"'+ convert( varchar(4), OccurrenceMonth) +'","range_start_picker":"'+(convert( varchar(4), DATEPART(MONTH, CreatedAt) ) +'/'+convert( varchar(4), DATEPART(DAY, CreatedAt))+'/'+convert( varchar(4), DATEPART(YEAR, CreatedAt)))+'","rangeOption":"1","Occurrences":"","range_picker":""}'
from Holiday h where h.Id =Holiday.Id) where OccurrenceType = 1 --FirstDayOfWeek = 1
GO