Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 586
DFord Avatar asked Mar 14 '12 19:03

DFord


2 Answers

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

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

like image 191
UnhandledExcepSean Avatar answered Sep 17 '22 17:09

UnhandledExcepSean


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

like image 26
specificityy Avatar answered Sep 20 '22 17:09

specificityy