2017-09-08 108 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/

相關問題