Solved

Azure - Join 2 Azure SQL Server databases

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Learn how the use of a bunch of disparate tools requiring a lot of manual attention led to a series of unfortunate backup events for one company.
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…
Both in life and business – not all partnerships are created equal. Spend 30 short minutes with us to learn:   • Key questions to ask when considering a partnership to accelerate your business into the cloud • Pitfalls and mistakes other partners…

810 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