DFord
DFord

Reputation: 2358

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? 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". Is my syntax wrong?

Upvotes: 10

Views: 25994

Answers (2)

specificityy
specificityy

Reputation: 580

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

Upvotes: 3

UnhandledExcepSean
UnhandledExcepSean

Reputation: 12804

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

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

Upvotes: 16

Related Questions