?
Solved

Create a view joining 2 servers?

Posted on 2003-02-28
3
Medium Priority
?
304 Views
Last Modified: 2012-08-13
Hi everybody.

I was wondering if it is possible to create a view or a query using 2 different servers in the same manner as it is possible to join 2 databases(select A.*, B.* from db1.dbo.table1 A INNER JOIN db2.dbo.table2 B on A.ID = B.ID).

Is it possible or is it a complete waste of time?

Thanks, Christophe
0
Comment
Question by:FraggleRock
[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 9

Accepted Solution

by:
mcallarse earned 1200 total points
ID: 8043125
It's possible using linked servers in MS SQL Server.
0
 
LVL 1

Author Comment

by:FraggleRock
ID: 8043317
Thanks mcallarse.
I've looked into linked database and came across some explanations. I tried to apply it but I have a problem.
In the query analyser, I've typed the following (of course, I've changed the login details before posting it here!):

USE master
GO
EXEC sp_addlinkedserver
   'SERVER1',
   '',
   'MSDASQL',
   NULL,
   NULL,
   'DRIVER={SQL Server};SERVER=companyserver;UID=userid;PWD=password;'
GO


select * from SERVER1.mydatabase.dbo.rtcompanies

##################
companyserver is the name of an ODBC Connection setup on my machine.
mydatabase is the database I want to access.
rtcompanies is the table I'd like to display.

I have the following error message:
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'MSDASQL' reported an error.  
[OLE/DB provider returned message: [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()).]
[OLE/DB provider returned message: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.]

I've checked the ODBC connection and it's fine.
I've tried the query:
select * from SERVER1.dbo.rtcompanies
but it says "Invalid object name 'SERVER1.dbo.rtcompanies'."

What am I doing wrong?
(I've increase the points to 300 available if you can help me sorting this out)

Thanks,
Christophe
0
 
LVL 1

Author Comment

by:FraggleRock
ID: 8043407
Well, I've found the right syntax:

USE master
GO
EXEC sp_addlinkedserver
   'SERVER1',
   '',
   'MSDASQL',
   'companyserver;UID=userid;PWD=password'
GO


select * from SERVER1.mydatabase.dbo.rtcompanies


Anyway, thank you mcallarse as you pointed me to the right topic to dig into. You can have those points.

Thanks a lot,
Christophe
0

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
In this article, we’ll look at how to deploy ProxySQL.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

770 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