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

时间:2022-10-25 16:55:18

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? I am trying to do this

我在与我查询的数据库不同的数据库中有一个用户定义的函数。有没有办法访问函数,如SQL中的完全限定名称或类似名称?我想这样做

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

But i get an error saying that it cannot find the column "dbo" or the user defined function "dbo.EscalationManagemntSystem.fncCVUnix2DateTZ". Is my syntax wrong?

但我得到一个错误,说它找不到列“dbo”或用户定义的函数“dbo.EscalationManagemntSystem.fncCVUnix2DateTZ”。我的语法错了吗?

2 个解决方案

#1


9  

The proper format is Database.Schema.Object, so you would have:

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

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

[EscalationManagementSystem] [DBO]。[fncCVUnix2DateTZ](...

#2


1  

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

#1


9  

The proper format is Database.Schema.Object, so you would have:

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

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

[EscalationManagementSystem] [DBO]。[fncCVUnix2DateTZ](...

#2


1  

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