• I founded that if I start the select twice, the second select is almost always the good time, but sometimes is same or worst,

    It is possible that can be problem in created temporary table?? and deleted ?? But in direct query is also and there isnt problem.

    SELECT WORK_DATE FROM FN_TABLE_GET_WORK_DATE()

    SELECT WORK_DATE FROM FN_TABLE_GET_WORK_DATE()

    SQL Server parse and compile time:

    CPU time = 0 ms, elapsed time = 0 ms.

    (1 row(s) affected)

    Table '#01014840'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    SQL Server Execution Times:

    CPU time = 31 ms, elapsed time = 28 ms.

    (1 row(s) affected)

    Table '#03DDB4EB'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    SQL Server Execution Times:

    CPU time = 0 ms, elapsed time = 3 ms.