Since there are more advantages of Stored procedures over UDFs, most of us think that stored procedures are the best always. There should be some reasons why UDFs were introduced in DBMS.
Below are the scenarios in which we should use UDFs only.
- Can Join the UDF output with another table. But we can’t write SELECT statements with Stored Procedures.
- Can call UDF in WHERE/HAVING clauses.