• We had issues with Functions taking a long time to run when using parameters where the scope might change each time it's run.

    To resolve the issue, it was quicker and more efficient to let the Function perform the full query unfiltered, then add the parameters purely in the stored procedure that calls it.

    Alternatively, unless you're using the Function many times in different SPs, just have the whole code in a stored procedure in full.