create linked server in azure sql database - azure

Want to create linked server in azure sql. I want to use local DB views in sql azure using linked server. Is it possible or is there any alternate way. All suggestions are welcome.

yes you can create linked servers in SQLAZURE...Assuming you have local on premises server A and database in azure say AZ_b..you can create a linked server for azure on your local on premise instance...
since you want to do this I want to use local DB views in sql azure using linked server. after creating linked server you need to run queries from server A which is your local onpremises server and this is the only way name resolution of linked server can happen and you can't do the other way
below are the steps
-- Supporse your database on Azure is named 'Azure_Test_DB'
EXEC sp_addlinkedserver
#server='myLinkedAzureServer', -- specify the name of the linked server
#srvproduct='',
#provider='sqlncli',
#datasrc='azure-test-db.database.windows.net', -- add here your server name
#location='',
#provstr='',
--------Change it by your need ------------------------------------------------------------------
#catalog='Azure_Test_DB' -- specify the name of database on your Azure DB you want to link
-------------------------------------------------------------------------------------------------
-- Configure credentials for Azure linked server
EXEC sp_addlinkedsrvlogin
#rmtsrvname = 'myLinkedAzureServer',
#useself = 'false',
--------Change it by your need ------------------------------------------------------------------
#rmtuser = 'yourLoginName', -- add here your login on Azure DB
#rmtpassword = 'yourPassword' -- add here your password on Azure DB
-------------------------------------------------------------------------------------------------
-- Configure options for Azure linked server
EXEC sp_serveroption 'myLinkedAzureServer', 'rpc out', true;
-- Now you can query the data using 4-part names
select * from myLinkedAzureServer.[Azure_Test_DB].[dbo].[Students];
once you create linked server , you can connect to server A and can run below queries
select * from
myLinkedAzureServer.[Azure_Test_DB].[dbo].[Students] az
join
localdb.dbo.table1 tbl
on tbl.somecol=az.somecol
References:
https://gallery.technet.microsoft.com/scriptcenter/How-to-create-linked-cb98fa7d
https://www.mssqltips.com/sqlservertip/3630/connect-an-azure-sql-database-to-an-onpremises-sql-server/
The above steps works for most of machines..incase it doesn't work, you need to setup a ODBC DSN by following the steps here..
https://blogs.msdn.microsoft.com/sqlcat/2011/03/07/linked-servers-to-sql-azure/

You cannot create a linked server in Azure SQL Database.
Microsoft does have a preview available of a new Instance as a Service offering that will allow you to perform cross database queries. It may also allow for linked servers. It's not yet widely available.
Now, you can use Elastic Query to set up something pretty similar. Here's a blog post I wrote on it. However, it's not the same as a linked server.

As a workaround to the limitation of linked servers not available on SQL Azure databases, you can replicate objects from on-premises SQL Server databases to SQL Azure or use SQL Data Sync to sync data between on-premises SQL Server and a SQL Azure server.
Hope this helps.

Related

Serverless Azure SQL - databases per server

As you can see in the screenshot below, a server needs to be selected or created in order to create an azure sql serverless database.
Can I reuse that server and create other azure sql serverless databases on it? If so, how many databases can be created using the same server?
I found the answer in the documentation:
Azure SQL Logical Server Limits
It's 5000 databases per logical server.

What extra one gets by selecting Azure SQL Managed Instance vis-a-vis Azure SQL DB PaaS

I would like to know what extra benefits one get by choosing Azure SQL Managed Instance compared to Azure SQL DB PaaS. I know SQL Managed Instance is offered as a vCore based purchasing model only. Apart from this what is the extra add on and benefits that one gets over the other. Any reply would be appreciated.
With Azure SQL Managed Instance, you essentially get a full fledged SQL Server that you can control any way you want, just like you would control a locally configured SQL Server. All the power and access and customization you want.
With, Azure SQL DB PaaS, you are essentially getting a database service, so, you give up a lot of control.
For example, take server collation. With the database service, SQL_Latin1_General_CP1_CI_AS , is all you get. With the Managed Instance, its your server. So, go ahead and select whatever collation you want, just like how you would select the collation at the time of creatoin.
Another issue is with auditing, if that is something that is important to your setup. with SQL Managed Instance, auditing happens at server level, because, you are getting the full database server. With the database service, it only database, because, you are only getting a database.
These are just the main details that I found. more details here at this Azure doc - https://learn.microsoft.com/en-us/azure/azure-sql/database/features-comparison
Of course, Managed is going to cost you more because you are paying for the license of the SQL server too.
Lastly, for me, this is the almost (not the exact same thing) like you running your own File Server on a Windows VM on Azure (Managed Instance) versus, just using Blob Storage. In both cases, you are just trying to store some files, but its how much control you have.
I would say think about Azure SQL DB vs Azure SQL Managed Instance (MI) as
Azure SQL DB = Resources dedicated to individual DBs like a container. They are grouped under a Azure SQL Server but that SQL Server is just for grouping.
Azure SQL MI = Almost same as on-prem SQL Server except you don't have to worry about OS, backups, high availability.
Here is a good comparison.
https://learn.microsoft.com/en-us/azure/azure-sql/database/features-comparison
Hopefully this will help
Azure SQL Database - The usual PaaS way. You have vCore, DTU, and Serverless billing mode. And Elastic pool support.
Azure SQL Managed Instance - Similar as below. When you want to use instance-scoped features of Azure SQL Managed Instance like Service Broker, CLR, SQL Server Agent, and Linked servers. As if you have an SQL Server on premise, Azure is responsible for patching, upgrading version etc.
SQL Server on Azure Virtual Machines - Similar as above. But you are responsible for OS and SQL server upgrade.

Need to sync data from one database in azure to another database where both databases have different location and different server

I'm trying to sync two databases in azure paas having different location and different server.
When I try to create a sync group I'm not able to see the database in other regions.
Sync two databases in different location using azure portal.
For your question, please see FAQ about SQL Data Sync:
What regions support Data Sync
SQL Data Sync is available in all regions.
Data Sync support you sync two databases in azure paas having different location and different server.
Did you followed this document: Tutorial: Set up SQL Data Sync between Azure SQL Database and SQL Server on-premises ?
For example I have two SQL database in different Azure SQL Server and region.
Server 1:
Server 2:
Set 'Mydatabase' database in Server 1 as Hub database, add the 'dbleon' database in Server 2 as member database:
Every thing works ok.
Hope this helps.

can an Azure-hosted SQL Server connect with an Azure Cosmos DB?

Not sure if this is an option? Ideally looking at something like an openrowset query from a stored procedure within SQL server or a web job.
If so, are there any resources available to help learn how to make SQL Server and Cosmos play nicely together?
If your SQL Server in Azure is managed by you on a VM (IaaS) you should be able to add the Cosmos DB as "SQL Server Linked Server" e.g. by adding as ODBC Source.
Then it's also optional if you link the Cosmos DB PaaS service to your Vnet or access it via public endpoints.
Not 100% sure if this will also succeed with Azure managed instances (which is quite new in GA).

Azure SQl Server Cross server Database Queries in Azure SQL Database

hi i have create 1 database in Azure SQL server .Now i want to create procedure using link server.And my other database is on different server not on Azure.So it is giving error .Please help
Linked servers are not supported in Sql Azure. If both servers were in Azure, you could used elastic database query to do cross database queries within the SQL Azure Server.
Perhaps you could give us a clearer idea of exactly what you're trying to do, and what the exact error is?

Resources