Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using SQL 2005 or 2008, is it possible to create a database called C that is a view into all tables in database A + B ? Databases A, B, and C are on the same local server.

I am wanting to be able to create join queries between tables that are in 2 different databases. Is there another way to do this?

share|improve this question
up vote 5 down vote accepted

You can create DatabaseC if you want to, but it adds no value. Just use 3 part object names:

   A.col1, B.col2
   DatabaseA.dbo.TableA A
   DatabaseB.dbo.TableB B ON A.xx = B.xx
share|improve this answer
What if this was an indexed view? You could materialize it into database C if this fit some purpose? – Tevo D Nov 22 '11 at 19:23
I can't believe I didn't think of that. I just didn't realize it was possible. It worked. Thanks! – djangofan Nov 22 '11 at 19:29
@TevoD - You can't SCHEMABIND to tables in other databases which is a requirement for indexed views. – Martin Smith Nov 23 '11 at 8:47
@MartinSmith to add some color to that: SQL Server can't maintain indexed view consistency across databases because they could be restored, copied and they are not crash consistent as a unit. – usr May 22 '15 at 20:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.