I hope someone can shed any light or guide me through using table-valued functions in SQL database.
I find a function dbo.NextAvailableSlot(@rostergroupid, @rosterfromdate, @rosterenddate, @rostercategoryid) in prod database, it returns next available time slot of a staff in a group. I can simply replace @rostergroupid, @rosterfromdate, @rosterenddate, @rostercategoryid with a set of values I want to and returns the result I want.
But how can I use it as part of SQL query to return values dynamically?
I have tried to outer apply it in querying roster tables, but it returns way too many rows (duplicated rows).