简体   繁体   English

如何在SQL中使用来自另一个db的用户定义函数

[英]How to use a user defined function in SQL that is from another db

I have a user defined function in a different database than the one i am querying from. 我在与我查询的数据库不同的数据库中有一个用户定义的函数。 Is there a way to access the function such as a fully qualified name or something similar in SQL? 有没有办法访问函数,如SQL中的完全限定名称或类似名称? I am trying to do this 我想这样做

[dbo].[EscalationManagementSystem].fncCVUnix2DateTZ(...

But i get an error saying that it cannot find the column "dbo" or the user defined function "dbo.EscalationManagemntSystem.fncCVUnix2DateTZ". 但我得到一个错误,说它找不到列“dbo”或用户定义的函数“dbo.EscalationManagemntSystem.fncCVUnix2DateTZ”。 Is my syntax wrong? 我的语法错了吗?

正确的格式是Database.Schema.Object,所以你有:

[EscalationManagementSystem].[dbo].[fncCVUnix2DateTZ](...

Every time you need to access objects from another db you should use something called the "four part name convention" which is: 每次需要从另一个数据库访问对象时,你应该使用一个名为“四部分名称约定”的东西,它是:

SERVER.DATABASE.SCHEMA.OBJECT SERVER.DATABASE.SCHEMA.OBJECT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM