can stored proc in SQL Server 2008 on-premise db reference a table in SQL Azure db
-
22-04-2021 - |
Pergunta
I can see my SQL Azure database in SQL Server Management Studio, and am able to execute queries, create objects, etc etc, in SSMS. The VPN is working.
I know there are (or will be) synchronization utilities available from Microsoft, but let's say we didn't want to use them. Is it possible for a stored procedure, running locally in an on-premise instance, to establish a connection to the remote (cloud) database, and then reference a table in the cloud as if it were local?
insert azure.dbo.clients CLOUD
select * from mylocaldb.dbo.clients EARTH
where EARTH.lastSyncDate is null
Is it possible to connect to the cloud database as to a linked server, to permit heterogeneous (earth/cloud) queries and data flow?
Solução
Yes, you will have to create a linked server entry in your local server and refer to the SQL Azure db as you would with any other linked server. You just have to create an ODBC DSN before you can create a linked server. Check Linked Servers to SQL Azure for details.
After that, you can execute a remote stored procedure by using its four-part name, eg:
EXEC [RemoteServer].DatabaseName.DatabaseOwner.StoreProcedureName params
Outras dicas
Although Panagiotis is correct, you need to know that there is a disclaimer about this "feature": it is not supported. Here is the official SQL Server support team statement regarding linked servers and SQL Azure: http://blogs.msdn.com/b/psssql/archive/2011/05/03/not-linkedservertosqlazure-where-provider-msdasql-and-dsn-sql-server-native-client.aspx