Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Can't join tables from two databases using linked servers ..

 
   Database Forums (Home) -> Connect RSS
Next:  IDS 11 RSS promotion to a primary in DR  
Author Message
acesover

External


Since: Feb 11, 2008
Posts: 4



(Msg. 1) Posted: Mon Feb 11, 2008 3:01 pm
Post subject: Can't join tables from two databases using linked servers when DBs on
Archived from groups: microsoft>public>sqlserver>connect (more info?)

Hi,

I've got two databases on the same SQL server instance and I've
created a linked server to that instance from my host SQL instance. I
was wondering if I can create a join between tables on the two
databases. It appears as though SQL server only recognizes the first
database referenced in the query. I've tried the following query:

select
A.fld1, B.fld2
from
linkedserver.databaseA.ownerA.tableA "A" JOIN
linkedserver.databaseB.ownerB.tableB "B"

But got this message:
OLE DB provider 'linkedserver' does not contain table
'"databaseB"."ownerB"."TableB"'. The table either does not exist or
the current user does not have permissions on that table.

If I switch the two lines around, the error occurs on the "A' database
instead of "B". If I only query one database, either one, all works
fine.

I tried creating an alias using the Client Network Utility and
referenced the alias for the B database in my query, but got the same
error. I also tried adding a second linked server using
sp_addlinkedserver, specifying database B in the catalog parameter,
but get the same error. If I run the sp_catalogs stored procedure, I
see both DatabaseA and DatabaseB in the result set.

Any ideas on where I am going wrong? Thanks.

Dan

 >> Stay informed about: Can't join tables from two databases using linked servers .. 
Back to top
Login to vote
acesover

External


Since: Feb 11, 2008
Posts: 4



(Msg. 2) Posted: Mon Feb 11, 2008 3:12 pm
Post subject: Re: Can't join tables from two databases using linked servers when [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Feb 11, 4:01 pm, acesover wrote:
> Hi,
>
> I've got two databases on the same SQL server instance and I've
> created a linked server to that instance from my host SQL instance. I
> was wondering if I can create a join between tables on the two
> databases. It appears as though SQL server only recognizes the first
> database referenced in the query. I've tried the following query:
>
> select
>   A.fld1, B.fld2
> from
>   linkedserver.databaseA.ownerA.tableA "A" JOIN
>   linkedserver.databaseB.ownerB.tableB "B"
>
> But got this message:
> OLE DB provider 'linkedserver' does not contain table
> '"databaseB"."ownerB"."TableB"'.  The table either does not exist or
> the current user does not have permissions on that table.
>
> If I switch the two lines around, the error occurs on the "A' database
> instead of "B". If I only query one database, either one, all works
> fine.
>
> I tried creating an alias using the Client Network Utility and
> referenced the alias for the B database in my query, but got the same
> error. I also tried adding a second linked server using
> sp_addlinkedserver, specifying database B in the catalog parameter,
> but get the same error.  If I run the sp_catalogs stored procedure, I
> see both DatabaseA and DatabaseB in the result set.
>
> Any ideas on where I am going wrong? Thanks.
>
> Dan

PLEASE IGNORE: It was a typo in my second reference that was causing
the problem.

 >> Stay informed about: Can't join tables from two databases using linked servers .. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
How do i join 2 databases on seperate servers? - Trying to extract data from two databases on different servers... I know how to write Select statements to get data from them seperately but have not managed to join the two together. Can anyone help with this issue? Thank you ck

Linked Servers and DNS - Is it possible to add a likned SQL Server using something other than the network name, ie the DNS name? What connection method/ protocol does SQL Server use to try to connect to another SQL Server linked server?

Linked Server: set up same on different servers, but diffe.. - We have a linked server set up the same on 2 servers, but a query from one server executes different on the remote database. A Query from one server executes quickly, while the other causes table scans on the remote server, per Profiler. I couldn't se...

error between linked servers (with sa login vs local user .. -

SQL2005: Linked Servers & Updating Text datatypes - I posted this in sqlserver.programming and did not get any responses. Trying again.. This bugged me in SQL2000 and seems to still be here in SQL2005. Here's repro code to run on two SQL2005 servers: Run this on the "remote server": Create...
   Database Forums (Home) -> Connect All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]