How to call a SQL Server user defined function? The SQL syntax to call a function is different from the call to a stored procedure. Use SQL Server function the same way you select data from a table.
How to call a SQL Server function?
A user-defined SQL Server function is a Transact-SQL program that accepts parameters as input. When called, it performs actions, such as reading a SQL table and returns a result as output. Input and output are not mandatory.
A SQL Server user-defined function is usually returning data, it can an empty result set, one line or multiple columns. For example, let’s call the function from this article on how to create a SQL Server function. The function displays the name of a customer based on the customer number.
With this second call example, we can also rename the result column to personalize the output.
SELECT dbo.ufnDisplayCustomers(1) AS [Customer Name];
For more in-depth and official information on SQL Server functions, read the MS documentation directly on the Microsoft site. The English documentation is usually richer and much more complete than any other non-English language. The database forum and support pages in English are also much more active than the other languages.