Home > Archive > MS SQL Server > January 2006 > Define FK over DB boundaries









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 Define FK over DB boundaries
Christian Havel

2006-01-13, 7:23 am

Hi,

is it possible to assign a foreign key from DB1 to a primary key from DB2?

Thanks
Christian
Ryan

2006-01-13, 7:23 am

Nope, it's not supported. You'd have to do it with triggers.

--
HTH. Ryan
"Christian Havel" < ChristianHavel@discu
ssions.microsoft.com> wrote in
message news:0FB2E334-A203-4BAF-BDA1- 71A4462E8841@microso
ft.com...
> Hi,
>
> is it possible to assign a foreign key from DB1 to a primary key from DB2?
>
> Thanks
> Christian



Jens

2006-01-13, 7:23 am

No, you have to implemt that with triggers.

BTW: Do not cross(-language) post.

HTH, jens Suessmeyer.

John Bell

2006-01-13, 9:23 am

Hi

You could add a check constraint that calls a function, but this is likely
to be very slow.

John

"Christian Havel" wrote:

> Hi,
>
> is it possible to assign a foreign key from DB1 to a primary key from DB2?
>
> Thanks
> Christian

Scott Morris

2006-01-13, 9:23 am

> You could add a check constraint that calls a function, but this is likely
> to be very slow.


Careful with this - real DRI works in two directions. This would only work
in one direction and only for inserts and updates.


John Bell

2006-01-13, 9:23 am

Scott

Both the trigger solution and the check constraint require changes to both
databases if you want to cover everything.

John

"Scott Morris" wrote:

>
> Careful with this - real DRI works in two directions. This would only work
> in one direction and only for inserts and updates.
>
>
>

Scott Morris

2006-01-13, 11:23 am

> Both the trigger solution and the check constraint require changes to both
> databases if you want to cover everything.


Nothing I wrote disagreed with this. But, as I mentioned, a check
constraint is not checked during deletion. A set of triggers, when properly
designed and written, can enforce the required relationship. As far as I
know, check constraints cannot wholely support the requirement.


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