i have 2 tables one is emp and another is emp1Step 1 : IN Stored procedure pass input empid,from_date and end_dateEx: EXEC shift1 9999,'2016-05-01','2016-05-20'First date it has to check for the entry of this employee in emp table(i.e) 9999,'2016-05-01' if record found then it is 'NIGHT SHIFT' if record not found then i should check with emp1 table if it is there then it is DAY SHIFTsecond date it has to check for the entry of this employee in emp table(i.e) 9999,'2016-05-02' if record found then it is 'NIGHT SHIFT' if record not found then i should check with emp1 table if it is there then it is DAY SHIFTThird date it has to check for the entry of this employee in emp table(i.e) 9999,'2016-05-03' if record found then it is 'NIGHT SHIFT' if record not found then i should check with emp1 table if it is there then it is DAY SHIFTLike that it has to continue for all 20 days(as per the exec statement above)Some sample data:Create table emp(emp_code int,Enddate DATETIME,shift INT,shifttype INT)INSERT INTO emp VALUES(635,'2014-05-03',2,1)INSERT INTO emp VALUES(635,'2014-11-22',2,1)INSERT INTO emp VALUES(635,'2015-10-28',1,1)Create table emp1 (empid INT,shift INT,shifttype INT)INSERT INTO emp1 VALUES(635,1,1)
↧