Solved

Azure - Join 2 Azure SQL Server databases

Posted on 2014-01-20
3
659 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now