0

Can a query running a selected database access a table on other database?
How do I grant this kind of access?
Going further, can a Foreign key be created among diferent databases?

I'm running around this doubts for a while. Any help is welcome.

[]s

2
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by fcaserio
0

If the user running the query has rights to select the table in the other database, you will be able to. the syntax is something like:

select * from tableA join otherDB.dbowner.tableB on tableA.x=tableB.y

where otherDB = the other database (if it contains a space, enclose it in square brackets like [Other Database])
dbowner = the database owner, usually dbo unless you do use different schemas, or have named them all differently

Nope, you can't create foreign keys across databases. 98% sure of this.. I've never tried, but I seriously doubt it.

Can a query running a selected database access a table on other database?
How do I grant this kind of access?
Going further, can a Foreign key be created among diferent databases?

I'm running around this doubts for a while. Any help is welcome.

[]s

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.