I have an UDF like this
CREATE FUNCTION Lob_function
(
    @policy NVARCHAR(MAX)
    @table  Table
)
RETURNS NVARCHAR(MAX)
AS 
BEGIN
select @policy= 
case
when @policy like '%AMM%' then 'AMM'
when @policy like '%MOT%' then 'MOT'
when @policy like '%MOX%' then 'MOX'
when @policy not like '00%' then LEFT(@policy,3)
end
from @table
return @policy
END;
I want to use my UDF for various cases like :
Select Lob_function (@policy, @table) from @table.
It appears an error on @table Table, when I replace @table by a fixed table, my UDF can be executed but very slowly compared with a normal Select statement.
 
     
    