0

How can I query multiple tables from multiple azure databases?

Imagine I have "customers" table in Database X and "sales" table in dabtabase Y and I want to join them in a query, how is it possible to do this in Azure?

hopper
  • 4,230
  • 8
  • 36
  • 49
  • Just to clarify: Are you specifically talking about Azure SQL Database service? – David Makogon Jan 24 '15 at 02:54
  • 1
    possible duplicate of [Can't Query between Databases in SQL Azure](http://stackoverflow.com/questions/11284998/cant-query-between-databases-in-sql-azure) – user272735 Jan 24 '15 at 11:08

3 Answers3

0

Assuming you're talking about Azure's SQL Database service, then no, you cannot have queries across two separate database instances. The queries are limited to the single database.

If you require queries spanning multiple databases, you'd need to install SQL Server on a VM.

David Makogon
  • 69,407
  • 21
  • 141
  • 189
0

David is correct -- currently Azure SQL DB doesn't support cross-database joins.

Is it possible for you to combine the two databases into a single DB, but use separate schema to keep the namespaces of objects separate? I am curious about the business reasons you are maintaining separate dbs. You can reach out to me directly at Stuarto Microsoft com.

Stuart Ozer
  • 1,354
  • 7
  • 7
-3

You can join them if they're hosted on the same server. Try this

SELECT a.userID, b.usersFirstName, b.usersLastName  FROM databaseA.dbo.TableA a inner join database B.dbo.TableB b  ON a.userID=b.userID
Waseem Hassan
  • 233
  • 2
  • 10