Comments and answers for "How to Execute Sql UDF function"https://ask.sqlservercentral.com/questions/2022/how-to-execute-sql-udf-function.html
The latest comments and answers for the question "How to Execute Sql UDF function"Answer by Bob Hovioushttps://ask.sqlservercentral.com/answers/2025/view.html
<p>A scalar function is basically an expression. You use it in a query just as you would a column name, variable, or formula. Obviously you have to pass parameters to it in the query.</p>
<pre><code>select colA, colB, @amt, colA+colB, dbo.ufNvarcharToAscii(colC)
</code></pre>
<p>Although this is outside the scope of your question, a scalar function should not be confused with a table-valued function. A scalar function produces a single result value, while a table-valued function can produce a set of rows and is used either like a table, or in conjunction with APPLY. <em>Inline</em> table-valued functions are treated much like views by the optimizer and can produce performance benefits over scalar functions when applied to a large number of rows.</p>
<pre><code>select * from dbo.tfnListOpenOrdersForCustomerNo(custno)
select c.custNo,c.custname,t.orderno
from dbo.Customers c
cross apply dbo.tfnListOpenOrdersForCustomerNo(custno) as t
</code></pre>Sun, 25 Oct 2009 11:09:45 GMTBob HoviousAnswer by Matt Whitfieldhttps://ask.sqlservercentral.com/answers/2024/view.html
<p>Say you have created that UDF - then you would call it with</p>
<pre><code>SELECT schema.functionname(parameter)
</code></pre>
<p>So you might say </p>
<pre><code>SELECT @asciiValue = dbo.ConvertToAscii(@nvarcharValue)
</code></pre>
<p>However, in this case, you would be well advised to use the ASC built in function.</p>Sun, 25 Oct 2009 11:08:40 GMTMatt Whitfield