April 29, 2008 at 4:17 am
Hi All,
I have a table [Vendor] in first database SAMPLEDB. And i have another table [Contract] in another database TESTDB. I need a foreign key in the [Contract] table (which is in TESTDB database) is reference to the other table [Vendor] which is present in the SAMPLEDB.
When i try to creating them through SQL, i received the following error message :
Msg 1763, Level 16, State 0, Line 1
Cross-database foreign key references are not supported. Foreign key 'SAMPLEDB..VENDOR'.
Is that possible to refer foreign key in external database or not?
If possible, please give solution for this. If not possible, please suggest some alternate way.
Thanks in Advance
April 29, 2008 at 4:54 am
As the error message already said, you cannot create foreign key relationshsips between databases.
As a workaround you could create create a check constraint.
[font="Verdana"]Markus Bohse[/font]
April 29, 2008 at 5:10 am
Thank u for your quick response.
April 29, 2008 at 7:31 am
A check constraint will work, but you take a performance hit so be careful.
I seem to remember there being some kind of 3rd party product for doing this so you may want to google it.
April 29, 2008 at 9:36 am
A check constraint will work. There are also ways to solve this with a trigger.
You might want to test a few options on both of those concepts and see which works best for you.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply