Solved

Azure - Join 2 Azure SQL Server databases

Posted on 2014-01-20
3
677 Views
Last Modified: 2014-11-12
I would like to join 2 Databases on my Azure cloud SQL Server, in an Azure cloud SQL Server stored procedure. From what I've read it's not so simple. Is there any solution?

Also, what's the best way to modify a cloud SQL Server stored procedure?
0
Comment
Question by:esak2000
  • 2
3 Comments
 
LVL 11

Expert Comment

by:John_Vidmar
ID: 39795069
Configure linked servers, and use 3 or 4-part object references within the stored-procedure, here's the 4 parts:
      server.database.owner.object

Often, the owner is dbo, so people omit it, 3-part obj-ref example:
SELECT	*
FROM	Database1..table1	a
JOIN	Database2..table2	b	ON	a.key = b.key

Open in new window

0
 

Author Comment

by:esak2000
ID: 39796908
Where do the linked servers reside, in the Azure SQL Server or in a local SQL Server DB that is managed by SSMS?
0
 
LVL 11

Accepted Solution

by:
John_Vidmar earned 500 total points
ID: 39799853
A stored-procedure (SP) must be installed in a database, any object references from that database do not need to be fully-qualified (assumes objects are in one schema).  If you want to access data from another database/source (of any supported technology) then you need to create a logical connection to that database/source (SQL Server calls this a linked-server).  If you try to use a 3-part or 4-part object-reference without a linked-server configured then you will receive the following error:
Msg 7202, Level 11, State 2, Line 11
Could not find server 'some database here' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers.

Open in new window

0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
The next five years are sure to bring developments that are just astonishing, and we will continue to try to find the balance between connectivity and security. Here are five major technological developments from the last five years and some predict…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question