Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Foreign Keys

Status
Not open for further replies.
Apr 10, 2003
49
US
I'm new at DBs and I was wondering can you create a foreign key between 2 DB's? If not can someone please let me know what I need to do. Here's my senerio, I am building a new DB and I have a column that need to reference another table. I already have a table that is in another DB (on the same server), I don't want to have to create this table in the new DB, so is there a way I can do this? Thanks
 
I don't believe you can set a foreign key between databases. What you can do is put a trigger on the table you want as a foreign key table which checks first to see if the value exists in the other table before doing the insert. And you could put a delete and update trigger on the primary key table which will delete or update any existing records in the table with the subordinate relationship in the other database id you want to maintain referential integrity.

Questions about posting. See faq183-874
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top