I have a table valued function which returns the boss of a person for a given day.
dbo.Bosses(@empId, @date)
How do I loop through this function with information from another?
I.e, I want to use Table B that has a date and employee Id and I want to use them as arguments to find all the bosses for each day inputted in Table B
Table B EmpId int hours float day datetime creator int
Assuming you have SQL Server 2005+
CROSS APPLY will only return results where the Bosses function returns results. Similary to an INNER JOIN.
OUTER APPLY will return results for every entry in TableB, similar to a LEFT JOIN.