• Not having anything to test with, this is a possible alternative that converts your multi-statement tvf into an inline tvf. Test it out and compare it to what you already have (you may want to change the name to do some head to head comparisions).

    drop function dbo.fDayCount;

    go

    CREATE FUNCTION [dbo].[fDayCount]

    (

    @WorkDate DATETIME

    )

    RETURNS @returntable TABLE

    AS

    return(

    SELECT

    workdate,

    companyID

    FROM

    dbo.table1

    INNER JOIN dbo.table2

    ON table1.a = table2.a

    WHERE

    date = @date

    AND companyid IN(select

    ds.Item

    from

    dbo.config

    cross apply dbo.DelimtedSplit8K(CompID,',') ds

    where

    configva = 'compidstring')

    );

    go