Home > Archive > MS SQL Server > October 2006 > Cross database integrity









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Cross database integrity
Tom McLeesh

2006-10-24, 6:38 pm

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

2006-10-24, 6:38 pm

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



David Browne

2006-10-24, 6:38 pm



"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


Roy Harvey

2006-10-24, 6:38 pm

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
Anith Sen

2006-10-24, 6:38 pm

>> Is it possible to create foreign key between to distinct SQL databases ?

No. Triggers are the usually suggested workaround.

--
Anith


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com