Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Reference function from other DB

Author  Topic 

Passero
Starting Member

12 Posts

Posted - 2008-01-21 : 09:25:24
I created a function in DB A and want to use it in DB B.
I have permission on both the DB's.

I thought i could do it with DBA..functionName but it doesn't work. DBA.functionname also doesn't work. I can't seem to find the correct syntax for it...

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-01-21 : 09:37:11
Yes you can by using three part name like Database_name.owner_name.function_name()

For scalar function:
select db1.dbo.fn_foo()

For Table-valued function:
select * from db1.dbo.fn_foo()


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Passero
Starting Member

12 Posts

Posted - 2008-01-21 : 09:57:48
oh thanks
it works :)
Go to Top of Page
   

- Advertisement -