I'm using MS SQL 2005 and when I create a function I need to put the schema name to call it:
select dbo.MyFunc
All my tables are also in "dbo" schema and I don't need the schema name to reference it, so I'd like to know if I'm missing some configuration that could do the same to functions.
User-defined functions are functions that you use to organize your code in the body of a policy. Once you define a function, you can call it in the same way as the built-in action and parser functions. Variables that are passed to a function are passed by reference, rather than by value.
Invoking User-Defined Functions Each UDF can be invoked in Transact-SQL statements, such as SELECT, INSERT, UPDATE, or DELETE. To invoke a function, specify the name of it, followed by parentheses.
You can use a user-defined function wherever you can use a built-in function. You can invoke a sourced or external user-defined scalar function in an SQL statement wherever you use an expression. For a table function, you can invoke the user-defined function only in the FROM clause of a SELECT statement.
Like functions in programming languages, SQL Server user-defined functions are routines that accept parameters, perform an action, such as a complex calculation, and return the result of that action as a value. The return value can either be a single scalar value or a result set.
Short answer, no it isn't.
You should consider to prefix all your database objects with the schema owner to avoid having sql server to "look it up".
It makes your statements more readable and gives a slight increase in performance (although you'd probably won't notice it).
Regards, Lieven
Unlike all the other database objects (tables, views and stored procedures), user defined functions always need the schema name when they are referenced. It's a quirk of SQL Server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With