Foreign Key from one database to another

  • I have my membership info separate from my products / sales database.

    There are a few tables that I would like share related data; however, they are in different databases.

    Is it possible to do something like a Foreign Key from one database table to another.

    How do we link related data from one database to another. FK_ Constraint

    thanks

    Dam again!

  • Hi

    I am afraid foreign keys can only be applied within the same database. If you wish to enforce data integrity across databases then you will have to

    write your own logic. Normally I use insert/update triggers for this or write it within the stored procedures that add/update/delete the data.

    Regards

    Richard...

    http://www.linkedin.com/in/gbd77rc

  • OK,

    Thanks.

    Dam again!

  • Search on Google. There are a couple of 3rd party utilities that make pseudo FK's that cross databases.

    Beware, you can do this with check constraints and/or triggers, but they always perform much more poorly than native FK relationships. You may find that it is better to allow your application to manage this data integrity if the tables are of significant size.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply