|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Cross database integrityIs 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 The short answer is no. The more complex answer is: Yes, you would have to
enforce cross database constraint integrity using a Trigger. There are security and other issues that will also have to be addressed. -- Show quoteArnie Rowland, Ph.D. Westwood Consulting, Inc Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous "Tom McLeesh" <tom.mcle***@gmail.com> wrote in message news:u7%23a7148GHA.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 Often, the quality of the responses received is related to our ability to
'bounce' ideas off of each other. In the future, to make it easier for us to give you ideas, and to prevent folks from wasting time on already answered questions, please: Don't post to multiple newsgroups. Choose the one that best fits your question and post there. Only post to another newsgroup if you get no answer in a day or two (or if you accidentally posted to the wrong newsgroup -and you indicate that you've already posted elsewhere). If you really think that a question belongs into more than one newsgroup, then use your newsreader's capability of multi-posting, i.e., posting one occurrence of a message into several newsgroups at once. If you multi-post appropriately, answers 'should' appear in all the newsgroups. Folks responding in different newsgroups will see responses from each other, even if the responses were posted in a different newsgroup. -- Show quoteArnie Rowland, Ph.D. Westwood Consulting, Inc Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous "Tom McLeesh" <tom.mcle***@gmail.com> wrote in message news:u7%23a7148GHA.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 |
|||||||||||||||||||||||