||SQL Server Tips by Gama and Naughter
Types of functions
There are three types of UDF's:
How to call a scalar UDF:
How to call a table-valued UDF:
SELECT * FROM UDFname()
How to call a scalar system function:
SELECT master.dbo.fn_varbintohexstr(cast('aa' as binary(2)))
How to call a table-valued system function:
SELECT * FROM ::fn_helpcollations()
According to the returned value functions (including UDF's) can be:
Deterministic - When the returned value is always the same for the
Nondeterministic - When the returned value is not exclusively
dependent from the input.
A UDF can be bound to the schema of any objects it references, such
as tables, views, and other UDF's. Binding is specified with the
SCHEMABINDING clause and the name of the object to be bound. The
main advantage of schema binding is that if a UDF is bound to an
object, the objectís schema cannot change unless the schema binding
is dropped first.
Prerequisites for binding
All views and UDF's referenced by the function must be
All objects referenced by the function must be from the same
database as the UDF.
All objects referenced by the function require the user to have
All objects referenced by the function are not referenced using
a two-part name.
The above book excerpt is from:
Turbocharge Database Performance with C++ External Procedures
Joseph Gama, P. J. Naughter