Can't query between databases in SQL Azure - azure

I have a SQL Azure Database Server and I need to query between the Databases but can't figure out how to accomplish this.
Here is the structure of my databases:
Server.X
Database.A
Database.B
Database.C
In Database.A I have a Stored Procedure that needs to retrieve data from Database.B. Normally, I would reference the database like SELECT * FROM [Database.B].[dbo].[MyTable] but this does not appear to be allowed in SQL Azure.
Msg 40515, Level 15, State 1, Line 16
Reference to database and/or server name in 'Database.B.dbo.MyTable' is not supported in this version of SQL Server.
Is there a way to do this on the database end?
In the final version Databases A & C will both need data from Database B.

Update:
As per Illuminati's comment and answer, the situation has changed since this answer was originally accepted and there is now support for cross database queries as per https://azure.microsoft.com/en-us/blog/querying-remote-databases-in-azure-sql-db/
Original Answer (2013):
Cross database queries aren't supported in SQL Azure. Which means you need to either combine the databases to prevent the need in the first place, or query both databases independently and basically join the data in your application.

Cross database queries are now supported in SQL Azure
https://azure.microsoft.com/en-us/blog/querying-remote-databases-in-azure-sql-db/

Azure SQL DB is previewing Elastic Database Query feature at this point in time that will help you query among Azure SQL DBs with some limitations. You can get detailed information about the feature here.

Related

Is it possible to rename Azure Synapse SQL Pool?

I am using an Azure SQL Database for our team's reporting and the data size right now is too big to handle by a single data (at least I think so, it has 2 fact tables with around 100m rows in each table).
The Azure SQL Database is named "operation-db" and the Synapse is named "operation-synapse".
I want to make the transition for my team become as smooth as possible. So I'm planning to copy all the tables, views, stored procedure and user-defined function over to Synapse.
Once I'm done with that, is there a way to rename "operation-synapse" to "operation-db" so the team doesn't have to go to their code base to change the name of the db?
Thanks!
It is not possible to rename a SQL Pool via SQL Server Management Studio and you will receive the following error:
ALTER DATABASE NAME statement is not supported in a Synapse workspace.
To update the name of a SQL pool, use the Azure Synapse Portal or the
Synapse REST API. (Microsoft SQL Server, Error: 49978)
The REST API however does list a move method to change names:
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/move?api-version=2019-06-01-preview
I couldn't get it to work though. YMMV. Not renaming your db shouldn't be a big deal though. Your team should feel comfortable with changing connection strings etc and it will help them understand they are moving to a different product (Synapse) with different characteristics.
Before you move to Synapse however, have you look at Clustered Columnstore indexes in Azure SQL DB? They are default type of index in a SQL Pool database but are also available in SQL DB. They can compress your data 5-10x so it might end up not that big at all. Columnstore is great for aggregate queries but less so for point lookups so have a think about your workload before you migrate.
100 million rows is not big enough for synapse. Cci data in each shard will only have 1 row group (1mil rows).
Consider using partitioning or CCI in your sql db itself.
Also what's your usage pattern? If you are doing point lookups and updates clustered indexes will perform better.
You can rename a Synapse database easily using the SSMS GUI. (I've just tried this on v18.8).
Just click once on the database name in the Object Explorer to select it, then press the F2 key to rename it.
The Synapse service must be running (i.e. not paused) for the rename to work.
You can rename Synapse database using T-SQL. The command is as follows:
ALTER DATABASE [OldSynapseDBName]
MODIFY NAME = [NewSynapseDBName]
Note you need to be connected to/issue the command from the master database otherwise it will not work.
The command takes can 30 seconds on 100GB DB and there are some caveats such as DB must not be used during operation.

Alternative of Azure elastic query?

We are having 20 database in Azure. From First database we are using Azure elastic query to fetch employee details from each database to show in ui. But elastic query is taking taking lot of time for only 500 rows.
Is there any alternative way to handle cross database querying in Azure.
Cross-DB query in SQL Server is generally a lot faster than Elastic Query. If you want cross-database queries in a PaaS service, please consider SQL Azure Managed Instance which supports multiple databases per instance like SQL Server does. You will find the cross-db perf to be similar to SQL Server cross-db intra-instance queries.
Best of luck

Near real-time ETL of Oracle data to Azure SQL

I have an Oracle DB with data that I need to load and transform into an Azure SQL Database. I have no control over either the DB nor the application that updates its data.
I'm looking at Azure Data Factory, but I really need data changes in Oracle to be reflected as near to real-time as possible.
I would appreciate any suggestions / insights.
Is ADF the correct tool for the job? If so, what is a good approach to use? If not suitable, what should I consider using instead?
For real-time you don't really want an ELT/ETL tool like ADF. Consider a replication agent like Attunity or (gulp at the licensing costs) GoldenGate.
I don't think Data Factory is not good for you. Yes you can copy data from Oracle to Azure SQL database with it. But like #Thiago Custodio said, we need need to do it to each table you have. That's too complicated.
Just reference: Copy data from and to Oracle by using Azure Data Factory.
As you said, you really need data changes in Oracle to be reflected as near to real-time as possible.
The migration/copy time must be very short. Then the data in Oracle and Azure SQL database could be same before the Oracle data changed next time. I searched a lot and didn't find any real-time copy tools. Actually, I think you want the copy could be something like 'data sync'.
I found this link Sync Oracle Database with SQL Azure, hope it could give some good ideas for you.
About the data migration or copy, You can using bellow ways:
SQL Server Migration Assistant for Oracle (OracleToSQL)
Azure Database Migration Service (DMS)
Reference tutorial:
Migrating Oracle Databases to SQL Server (OracleToSQL): SQL Server Migration Assistant (SSMA) for Oracle is a comprehensive environment that helps you quickly migrate Oracle databases to Azure SQL database.
How to migrate Oracle to Azure SQL Database with minimum downtime:
Hope this helps.
For the record, we went with a product named QLik Replicate (aka Attunity) and it is working very well!

SQL Server to Azure Cosmos DB Migration

Please let me know whether we can migrate stored procedure from Microsoft SQL server to Microsoft Azure Cosmos DB ?
Either with DocumentDB migration tool or any other tool
There's really no direct correlation between the two: Stored procedures within the two databases are completely different. No possible way to migrate them, aside from you doing a complete rewrite. SQL Server stored procedures are written in SQL, vs Cosmos DB's JS-based stored procedures. Plus there is the notion of partitions, context, etc.
And Cosmos DB doesn't offer SQL Server compatibility and isn't a relational database. The Core (SQL) API takes advantage of SQL query language, but only for queries.

Migrating DB With Encrpytion

Recently I was informed that Azure SQL V12 now supports
databases that use encryption. I have tried all methods documented here,
https://azure.microsoft.com/en-us/documentation/articles/sql-database-migrate-ssms/
When attempting to migrate a database I get these kind of errors:
[dbo].[someitem] cannot be deployed as the script body is encrypted
Here is a recent response from an Azure AMA,
https://www.reddit.com/r/AZURE/comments/3o1ea9/ama_azure_app_service_team_109/cvu7xco
what am I doing wrong to get this feature working? As I believe I have performed all the steps as documented.
Azure SQL Database V12 supports two types of encryption:
Transparent Data Encryption as documented here: https://msdn.microsoft.com/en-us/library/dn948096.aspx.
Cell Level Encryption: https://msdn.microsoft.com/library/ms179331.aspx and http://blogs.msdn.com/b/sqlsecurity/archive/2015/05/12/recommendations-for-using-cell-level-encryption-in-azure-sql-database.aspx
Which of these are you trying to use?
Do you need to migrate the database between 2 different Azure SQL DB servers or between an on premise SQL Server and Azure SQL DB?
Between 2 Azure SQL DB servers, you can do a true backup restore via CREATE DATABASE ... AS COPY OF... syntax (https://msdn.microsoft.com/en-us/library/dn268335.aspx). This works because the key is in the database backup.
Between SQL Server and Azure SQL DB, there is no term plan to support moving of encrypted procedures or views.
If you could elaborate why you are encrypting procedures and views, that would help us understand the problems you are trying to solve. Many of the scenarios we've encountered in the past where customers desired procedure and view encryption with SQL Server don't apply to Azure SQL Database, but we're always learning of new challenges people have protecting their databases.

Resources