I am using sql server 2008 rc2 and I have a question about naming conventions for scalar valued functions. Specifically the following code works fine
select from database.dbo.MyUDF('arg')
but when I get rid of the dbo and try:
select from database..MyUDF('arg')
I get a syntax error saying that this is ambiguous. I never use the dbo in the name of an object for tables, views, stored proc’s or table valued functions and I never get this problem.
Why do I get this problem for a scalar udf?
First:
If you don’t use dbo notation, then it means you’re working with sysadmin rights. Otherwise you’d end up with [domain\user].Mytable for example on CREATE. Bad practice. At runtime, it attempts to resolve the user’s schema before looking at dbo = slower performance.
Second:
Try using SYNONYMS
Note, Synonyms may require explicit permissions (but sounds like you’re using sa or dbo anyway) and I’ve not used them with the database prefix so YMMV