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
 General SQL Server Forums
 New to SQL Server Programming
 How t create relationship b/w two tables

Author  Topic 

jogin malathi
Posting Yak Master

117 Posts

Posted - 2007-04-09 : 01:43:06
Hi
I have two database as Malathi,Indoo
In Malathi database i have

Employee Table AS
----------------------

Eid Int (PK)
Enam varchar(50)



In Indoo Database I have

Job table as

Eid int (FK)
Jid Int (PK)


Now how can i create relation b/w two tables of different database
Any One can help for this query

Malathi Rao

PeterNeo
Constraint Violating Yak Guru

357 Posts

Posted - 2007-04-09 : 02:46:02
No, it is not possible to create foreign key relationship between tables in two different databases.

According to BOL ( 2000)
" A FOREIGN KEY constraint can reference columns in tables in the same database or within the same table "
Go to Top of Page

jogin malathi
Posting Yak Master

117 Posts

Posted - 2007-04-09 : 02:58:57
then how we use two different database without creating relationships b/w tables
quote:
Originally posted by PeterNeo

No, it is not possible to create foreign key relationship between tables in two different databases.

According to BOL ( 2000)
" A FOREIGN KEY constraint can reference columns in tables in the same database or within the same table "



Malathi Rao
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-09 : 03:03:43
use 3 part naming


select *
from db1.dbo.tab1 t1 inner join db2.dbo.tab2 t2
on t1.somecol = t2.somecol



KH

Go to Top of Page
   

- Advertisement -