Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 OPENROWSET question

Author  Topic 

josh2009
Yak Posting Veteran

81 Posts

Posted - 2009-10-21 : 09:25:22
Hi,

I am trying to query two tables from different databases using an inner join and I keep getting the error message -

Msg 7314, Level 16, State 1, Line 1
The OLE DB provider "SQLNCLI" for linked server "(null)" does not contain the table ""dbo"."SERVER1"."patientnames"". The table either does not exist or the current user does not have permissions on that table.

I have ran the statement - sp_configure 'Ad Hoc Distributed Queries', 1 and then reconfigure so I know that the run value of Hoc Distributed Queries is already one when I do sp_configure. My query is -

SELECT a.patient_id, a.last_name, a.first_name, a.middle_name, a.date_of_birth, a.gender, b.id, b.lastname, b.firstname, b.middlename, b.birthdate, b.sex
FROM Demographics a
INNER JOIN OPENROWSET('SQLNCLI', 'DRIVER={SQL Server};SERVER=SERVER1;Trusted_Connection=yes;', dbo.DATABASE2.patientnames) b
ON a.patient_id = b.id

Is it really the permissions that is keeping me from running this query? When I just do a simple select statement from the other database, I am able to do so. But with the join, I am getting the error message. Any help wil be greatly appreciated. Thanks
   

- Advertisement -