I want ,I marked Holiday in #MonthDate column Holiday with 'H',
when employee Duty is marked with '0' before Holidays('H') and after 'Holidays('H') in table #MonthDate.Then update query required, which will check and marked that day with '2'.as i attached image for expected output.
Second condition
when employee Duty is marked with '0' before 'Sun' means ('Sat') and after 'Sun' means ('Mon') in table #tbl_Emp_Register.Then update query required, which will check and marked that day with '2'.as i attached image for expected output.
Create table #EmpMaster (EnrollNumber int, empName varchar(50))
Create table #MonthDate (Day varchar(50),Date date,Holiday varchar(50))
Create table #tbl_Emp_Register (EnrollNumbeR int,Date date,Day varchar(5),Duty int)
Insert into #EmpMaster values (10001,'ALi')
Insert into #MonthDate values ('Wed','2022-11-01',null)
Insert into #MonthDate values ('Thu','2022-11-02',null)
Insert into #MonthDate values ('Fri','2022-11-03',null)
Insert into #MonthDate values ('sat','2022-11-04',null)
Insert into #MonthDate values ('Sun','2022-11-05',null)
Insert into #MonthDate values ('Mon','2022-11-06',null)
Insert into #MonthDate values ('Tue','2022-11-07',null)
Insert into #MonthDate values ('Wed','2022-11-08',null)
Insert into #MonthDate values ('Thu','2022-11-09',null)
Insert into #MonthDate values ('Fri','2022-11-10',null)
Insert into #MonthDate values ('Sat','2022-11-11',null)
Insert into #MonthDate values ('Sun','2022-11-12',null)
Insert into #MonthDate values ('Mon','2022-11-13',null)
Insert into #MonthDate values ('Tue','2022-11-14',null)
Insert into #MonthDate values ('Wed','2022-11-15',null)
Insert into #MonthDate values ('Thu','2022-11-16','H')
Insert into #MonthDate values ('Fri','2022-11-17','H')
Insert into #MonthDate values ('Sat','2022-11-18','H')
Insert into #MonthDate values ('Sun','2022-11-19','H')
Insert into #MonthDate values ('Mon','2022-11-20',null)
Insert into #MonthDate values ('Tue','2022-11-21',null)
Insert into #tbl_Emp_Register values (10001,'2022-11-01','Wed' ,1)
Insert into #tbl_Emp_Register values (10001,'2022-11-02' ,'Thu',1)
Insert into #tbl_Emp_Register values (10001,'2022-11-03','Fri',1)
Insert into #tbl_Emp_Register values (10001,'2022-11-04','Sat',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-05','Sun',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-06','Mon',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-07','Tue' ,1)
Insert into #tbl_Emp_Register values (10001,'2022-11-08','Wed' ,1)
Insert into #tbl_Emp_Register values (10001,'2022-11-09' ,'Thu',1)
Insert into #tbl_Emp_Register values (10001,'2022-11-10','Fri',1)
Insert into #tbl_Emp_Register values (10001,'2022-11-11','Sat',1)
Insert into #tbl_Emp_Register values (10001,'2022-11-12','Sun',1)
Insert into #tbl_Emp_Register values (10001,'2022-11-13','Mon',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-14','Tue' ,1)
Insert into #tbl_Emp_Register values (10001,'2022-11-15','Wed' ,0)
Insert into #tbl_Emp_Register values (10001,'2022-11-16' ,'Thu',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-17','Fri',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-18','Sat',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-19','Sun',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-20','Mon',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-21','Tue' ,1)
Output

![]()