Sql-server – replace user defined functions (UDF) and tabled value functions(TVF)

functionsset-returning-functionssql-server-2017

Are there techniques to replace

  • UDF
  • tabled value functions
    with something else?

or techniques to make them acceptable? (fast, multithreading and with good estimations)

Best Answer

No easy way unless you are on SQL2017 for table valued functions and not UDFs.

However on SQL 2019 scalar UDFs May perform little better but there are still lots of catches involved

By default parallelism is inhibited while using the UDFs within code, mind you the function part itself can go parallel though.

Your best part if not on latest sql server version would be to inline the function. That is simply copying the work of function inside your code rather than calling function from the code.