Use Option (Recompile) in the built-in table function

Can it be used OPTION (RECOMPILE)in the built-in table function?

I try to use this, but it gives me an error. If it cannot be used, what other way is recommended to recompile the built-in table function?

My code will look like

ALTER FUNCTION [dbo].[fn_abcwork]
(
  @Date date
  , @id VARCHAR(MAX)
)
RETURNS TABLE
AS
RETURN
  SELECT a.name
    , a.age
    , a.title
    , b.work
  from tbl_abc a
  left outer join tbl_emp on a.id=b.id
+5
source share
1 answer

Built-in table functions Functions are expanded into the calling query, so nothing is actually called. Put OPTION(RECOMPILE)in a query that uses a function.

+3
source

Source: https://habr.com/ru/post/1621399/


All Articles