Your SP ends with a SELECT statement which returns the values to the calling application.
(
EXACTLY the same as yesterdays post requesting this to update a table)
What you would need to do if you wanted this data to be inserted into your table would be to build an
INSERT
statement for the EmployeeAttendance table.
(
as opposed to the UPDATE statement I wrote for you yesterday)
You are going to need to double check the mappings of these columns, did the best I could with what you had
INSERT EmployeeAttendance (EMPID, INTIME, OUTTIME, [HOURS], DUTY, OT, OTAmount, Late)
select cte.EmpID
, cte2.INTIME
, cte2.OUTTIME
, cte2.[Hours]
, CASE
WHEN cte2.[Hours] >= 8 THEN 1
WHEN cte2.[Hours] = 0 THEN 0
WHEN cte2.[Hours] >= 6 THEN 0.5
END AS [Day]
, CASE
WHEN cte2.[Hours] > CTE.Dhour then cte2.[Hours] - CTE.Dhour
else 0
End as OT
, CASE
when cte.OTEntitled = 'Yes' AND cte2.[Hours] >= CTE.Dhour THEN (( cte2.[Hours] - 8) * 100)
else 0
END AS OTAMount
, Convert(varchar(10), cte2.INTIME,108) as [Time]
, Case
When Convert(Time, cte2.INTIME,108) > cte.LTime Then 1
else 0
end as Late
from cte Cross Apply Dates d
Left Join cte2 ON cte2.EmpId= cte.EmpID AND cte2.Date=d.ReportingDate
Please note
- ORDER BY was removed, is immaterial to this
- You have dates in the select portion, but not in EmployeeAttendanceTable
- No clue if DUTY mapped to Date
- The DATE type does not have a "format" to it. While you can include the code it does nothing