Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Create a view joining 2 servers?

Posted on 2003-02-28
3
Medium Priority
?
309 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
  • 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

575 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