Foreign key relationship between two databases in SQL Server 2008

I have two databases, is it possible to create a foreign key between two tables in different databases in SQL Server 2008?

thanks

+6
source share
2 answers

From books on the Internet :

A FOREIGN KEY constraint can refer to columns in tables in the same database or within the same table.

Therefore, you cannot create foreign key constraints between two tables in different databases.

This is one of the disadvantages of using multiple databases.

+8
source

If you use Linq2Sql or an entity infrastructure, you can do this in the designer.

But as Igor says, you cannot do this in the database itself.

+1
source

Source: https://habr.com/ru/post/901979/


All Articles