A UDF can be used to write custom business logic. UDFs can only be called from inside queries. A good example of a UDF inside our domain is produced by creating a function that calculates the price of a device including VAT.
UDFs can be created on the Azure portal, just like stored procedures and triggers. This UDF can be defined in the following way:
If the VAT exceeds 100 percent, the function just returns the price (the VAT is then probably invalid or a mistake). Otherwise, it returns the original price including VAT. Testing this UDF involves a simple query.
The UDF can also be included inside WHERE
clauses of our queries.