I am using sql server 2008 rc2 and I have a question about naming conventions for scalar valued functions. Specifically the f开发者_如何学Collowing 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
CREATE SYNONYM MyUDF FOR dbo.MyUDF
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
精彩评论