Elastic Query in Azure SQL Database and Views

Azure
The question came up, how do the constructs necessary for Elastic Query within Azure SQL Database affect your ability to create views that join across databases. Since I haven't tested this myself, and I haven't seen anyone else doing anything with it yet, I decided to set up a test. I recreated my cross database queries using the scripts posted here. Let's create a view: CREATE VIEW dbo.JoinedView AS SELECT dt.Val, dt2.Val AS Val2 FROM dbo.DB1Table AS dt LEFT JOIN dbo.DB2Table AS dt2 ON dt2.ID = dt.ID; If I run the query, I get back results. Done. We can create views that join between Azure SQL Databases... But, views are all about masking right? What if I wanted to change the name of the table on my database. Could I…
Read More

Cross Database Query in Azure SQL Database

Azure
You can't query across databases in Azure SQL Database... or can you? Let's check. I've created two new databases on an existing server: I've created two tables on each respective database: CREATE TABLE dbo.DB1Table ( ID INT IDENTITY(1, 1) NOT NULL PRIMARY KEY, Val VARCHAR(50) ); CREATE TABLE dbo.DB2Table ( ID INT IDENTITY(1, 1) NOT NULL PRIMARY KEY, Val VARCHAR(50) ); Now, let's query the DB2 table from the DB1 database: SELECT * FROM DB2.dbo.DB2Table AS dt; And here's the lovely error message: Msg 40515, Level 15, State 1, Line 35 Reference to database and/or server name in 'DB2.dbo.DB2Table' is not supported in this version of SQL Server. So, like I said, you can't do three part name cross-database queries in Azure SQL Database... oh wait, that's not quite what I said…
Read More