Is it possible to call a user-defined function without the schema name?

后端 未结 3 880
野的像风
野的像风 2020-12-17 10:35

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 \

相关标签:
3条回答
  • 2020-12-17 10:54

    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.

    0 讨论(0)
  • 2020-12-17 11:02

    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

    0 讨论(0)
  • 2020-12-17 11:15

    *Scalar-valued functions must be invoked by using at least the two-part name of the function

    http://msdn.microsoft.com/en-us/library/ms186755.aspx

    +1 Parent

    Borik

    0 讨论(0)
提交回复
热议问题