Thursday, June 14, 2007

SQL Server Error : 'function_name' is not a recognized name

A silly issue, but may bug you if you are not a regular sql server udf user.

Whenever a scalar-valued user defined function is invoked just using the name of the function, single part, you will get an error like -

Msg 195, Level 15, State 10, Line 1
'function_name' is not a recognized function name.

To resolve this use at least two part function name (by prefixing it with owner).
example :
(1) Select MyScalarFunction() -- wrong usage
(2) Select dbo.MyScalarFunction() -- correct usage


Important thing to note is that table-valued function, unlike scalar-valued, can be called using single part name.

Tip: to avoid using multi part naming in sql server 2005, you can use synonyms.

[more reading on user defined functions]

No comments: