Tuesday, February 14, 2012

Cross database integrity

Is it possible to create foreign key between to distinct SQL databases ?
Database A contains table [customers] (primary key : customer_id)
Database B contains table [invoices] (each invoice should be linked to
a customer. Foreign key : customer_id)
I would like to create an integrity constraint between
[invoices].[customer_id] and [customers].[customer_id], despite the fact
that [invoices] et [customers] tables are in SEPARATE databases.
Is it possible to do that ?
Thanks in advance
Tom
Tom
> Is it possible to create foreign key between to distinct SQL databases ?
No
"Tom McLeesh" <tom.mcleesh@.gmail.com> wrote in message
news:u2njv248GHA.4572@.TK2MSFTNGP02.phx.gbl...
> Is it possible to create foreign key between to distinct SQL databases ?
> Database A contains table [customers] (primary key : customer_id)
> Database B contains table [invoices] (each invoice should be linked to a
> customer. Foreign key : customer_id)
> I would like to create an integrity constraint between
> [invoices].[customer_id] and [customers].[customer_id], despite the fact
> that [invoices] et [customers] tables are in SEPARATE databases.
> Is it possible to do that ?
> Thanks in advance
> Tom
|||"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:eh1pb548GHA.4288@.TK2MSFTNGP02.phx.gbl...
> Tom
> No
>
And a desire to implement referential integrity between databases usually
indicates that you shouldn't be using different databases.
Perhaps multiple schemas in a single database?
David
|||On Thu, 19 Oct 2006 16:54:00 +0200, "Uri Dimant" <urid@.iscar.co.il>
wrote:

>Tom
>No
But it would be possible to write triggers on the tables in both
databases to enforce the relationship.
Roy Harvey
Beacon Falls, CT
|||>> Is it possible to create foreign key between to distinct SQL databases ?
No. Triggers are the usually suggested workaround.
Anith

No comments:

Post a Comment