Solved

Azure - Join 2 Azure SQL Server databases

Posted on 2014-01-20
3
685 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

Question has a verified solution.

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

Optimized for private cloud infrastructures and datacenters, Nano Server is minimalistic, yet super-efficient, OS for services such as Hyper-V and Hyper-V cluster. Learn how you can easily deploy Nano Server and unlock its power!
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

732 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