开发者

select scalar valued udf sql server

开发者 https://www.devze.com 2023-01-30 03:50 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消