I have a Azure SQL database and it has a stored procedure from where I am trying to join a table which resides in on-premise SQL server database. Essentially, I am trying to query a table which sits in on-premise SQL server's database.
Are there any options to make cross-server queries from Azure SQL database?
Edit: I looked into the linked servers as mentioned in the comments but it seems linked servers do not work with Azure SQL Database Singleton and Elastic pools. They are enabled for SQL Server Database Engine and Azure SQL Managed Instance.
-
1Voted to move to Database AdministratorsFilburt– Filburt2021年02月25日 12:57:48 +00:00Commented Feb 25, 2021 at 12:57
-
1You want to look into linked servers learn.microsoft.com/en-us/sql/relational-databases/… that being said, an on premise instance is likely behind a firewall etc. so you will have networking considerationsDarkwing– Darkwing2021年02月25日 12:58:59 +00:00Commented Feb 25, 2021 at 12:58
-
You'll need an On-Premise Data Gateway - I found this tutorial.Filburt– Filburt2021年02月25日 13:01:08 +00:00Commented Feb 25, 2021 at 13:01
-
1Reversing the direction and creating a linked server from on-premise to Azure SQL is considerably easier if that is an option for your process.Filburt– Filburt2021年02月25日 13:02:20 +00:00Commented Feb 25, 2021 at 13:02
2 Answers 2
Azure SQL database does not support linked servers or Polybase so you cannot directly virtualize the data from your on prem to your cloud db.
If the requirement is to access the data in the on-prem instance from the Azure SQL database and some delay on the latest data is acceptable, your options are:
Replicate the data from the on prem instance to the azure db. This is most "automated" way to do it. See https://learn.microsoft.com/en-us/azure/azure-sql/database/replication-to-sql-database
Use DataFactory, SSIS or other ingestion method to copy the data yourself.
Hope this helps.
-
Thanks Fernando for your prompt response. In my requirement I don't want to replicate the data of on-premise SQL. I want to access it by joining it in a stored procedure. Any ways to do that?Anirud Thapliyal– Anirud Thapliyal2021年02月25日 14:47:45 +00:00Commented Feb 25, 2021 at 14:47
-
As far as I know Azure SQL database does not support linked servers or Polybase so you cannot directly virtualize the data from your on prem to your cloud db.Fernando Sibaja– Fernando Sibaja2021年02月25日 14:48:48 +00:00Commented Feb 25, 2021 at 14:48
-
There are elastic queries for SQL Database in preview, but I don't think you can link to on-prem. The documentation isn't very clear on this point, though: learn.microsoft.com/en-us/azure/azure-sql/database/…. Or maybe I didn't find the info when reading...Tibor Karaszi– Tibor Karaszi2021年02月25日 15:02:54 +00:00Commented Feb 25, 2021 at 15:02
-
The elastic pool deals with the problem of horizontal scaling and there has to be a good degree of control over a database cluster to do sharding. I don't believe an on prem instance will ever be supported. My understanding of the question is that it is about data virtualization, not scaling.Fernando Sibaja– Fernando Sibaja2021年02月25日 15:08:17 +00:00Commented Feb 25, 2021 at 15:08
-
Was that a reply to me? I didn't mention elastic pools, I referred to elastic queries. Anyhow, I agree that it is unlikely that on prem will be supported for elastic queries.Tibor Karaszi– Tibor Karaszi2021年02月25日 18:26:22 +00:00Commented Feb 25, 2021 at 18:26
I am not aware of a process for doing this natively.
You can use other services (I understand that is not what is asked in the question). For example (not a complete example):
- Azure Data Factory
- Azure Functions
- Azure automation (Notebooks)
Explore related questions
See similar questions with these tags.