2017-09-08 109 views
0

想要在azure sql中创建链接服务器。我想在使用链接服务器的sql azure中使用本地数据库视图。有没有可能或有任何替代方法。所有建议都欢迎。在azure sql数据库中创建链接服务器

+0

https://docs.microsoft.com/en-us/azure/sql-database/sql-database-features; TL; DR没有链接服务器 – user6144226

+0

链接或复制? – 4c74356b41

回答

0

您不能在Azure SQL数据库中创建链接服务器。

Microsoft确实提供了一个新的实例作为服务产品的预览版,可以让您执行跨数据库查询。它也可能允许链接服务器。它尚未广泛使用。

现在,您可以使用Elastic Query设置一些非常相似的东西。这是我写的一个blog post。但是,它与链接服务器不同。

0

作为解决SQL Azure数据库上不存在的链接服务器限制的一种解决方法,您可以将本地SQL Server数据库中的对象复制到SQL Azure或使用SQL Data Sync在本地SQL Server和SQL Azure服务器。

希望这会有所帮助。在SQLAZURE

1

是你可以创建链接的服务器假定你有在蔚蓝的本地服务器A和数据库的本地说AZ_b..you可前提比如在本地创建一个蔚蓝色的链接服务器...

既然你想创建你需要运行从服务器A的查询是当地onpremises服务器链接服务器后,要做到这一点I want to use local DB views in sql azure using linked server.,这是唯一的方法名称解析链接服务器可能发生,你不能做其他的way

以下是步骤

-- 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]; 

一旦创建链接的服务器,您可以连接到服务器A和可以在下面运行查询

select * from 
myLinkedAzureServer.[Azure_Test_DB].[dbo].[Students] az 
join 
localdb.dbo.table1 tbl 
on tbl.somecol=az.somecol 

参考文献:
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/

上述步骤适用于大多数的机器..因为它不起作用,您需要按照这里的步骤设置ODBC DSN ..

https://blogs.msdn.microsoft.com/sqlcat/2011/03/07/linked-servers-to-sql-azure/

相关问题