Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

SELECT from OPENDATASOURCE error Expand / Collapse
Author
Message
Posted Friday, February 15, 2013 8:35 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, July 11, 2014 1:42 PM
Points: 95, Visits: 603
I am trying to select from a table that is stored on a different server, I am using opendatasource. When I run the query, I get:

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

The select statement is as following:

select *
from OPENDATASOURCE('SQLNCLI',
'Data Source=DESTSERVR\INSTANCE;Integrated Security=SSPI').[TESTTBL].dbo.[TBLNAME]

Both database and table do exist on the destination server, I tested the same query from another server and it works. I did query all environments sysservers, and they are all setup identical, please advice.

Lava



Post #1420587
Posted Friday, February 15, 2013 9:17 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:02 PM
Points: 7,081, Visits: 12,574
Check that the Windows account you're using to log into the SQL Server with has a login and permissions to select from that table on the remote server. If it does then make sure the server's can reach each other, i.e. that network connectivity is possible.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1420618
Posted Friday, February 15, 2013 9:27 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, July 11, 2014 1:42 PM
Points: 95, Visits: 603
Forgot to mention that when I run the queries on different instances same box, it works... However, it does not work when I do distributed query, from one box to another...


Post #1420621
Posted Friday, February 15, 2013 9:49 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:02 PM
Points: 7,081, Visits: 12,574
opc.three (2/15/2013)
Check that the Windows account you're using to log into the SQL Server with has a login and permissions to select from that table on the remote server. If it does then make sure the server's can reach each other, i.e. that network connectivity is possible.


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1420639
Posted Friday, February 15, 2013 11:13 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, July 11, 2014 1:42 PM
Points: 95, Visits: 603
When I go to linked server, I can see the system catalogs. Below is how I created the the linked server:

EXEC sp_addlinkedserver
@server=N'Webdev',
@srvproduct=N'',
@provider=N'SQLNCLI',
@datasrc=N'DESTSERVR\INSTANCE';

The security is set to "Ba made using the login's current security context.

My account is set as admin to the server on both nodes.

Lava



Post #1420694
Posted Friday, February 15, 2013 11:45 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:02 PM
Points: 7,081, Visits: 12,574
lsalih (2/15/2013)
When I go to linked server, I can see the system catalogs. Below is how I created the the linked server:

EXEC sp_addlinkedserver
@server=N'Webdev',
@srvproduct=N'',
@provider=N'SQLNCLI',
@datasrc=N'DESTSERVR\INSTANCE';

The security is set to "Ba made using the login's current security context.

My account is set as admin to the server on both nodes.

Lava

Linked Servers are not in play when using OPENDATASOURCE. If you have a working Linked Server then maybe try this instead:

select * 
from [DESTSERVR\INSTANCE].[TESTTBL].dbo.[TBLNAME]



__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1420709
Posted Friday, February 15, 2013 11:50 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, July 11, 2014 1:42 PM
Points: 95, Visits: 603
My mistake, I am not using openquery but opendatasource... I got confused as I was trying to see what the issue is... Anyhow, in any cases, security might not be an issue as I have admin access to all boxes.




Post #1420712
Posted Friday, February 15, 2013 12:02 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:02 PM
Points: 7,081, Visits: 12,574
Who said anything about OPENQUERY? You do not need OPENDATASOURCE to work with a Linked Server.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1420716
Posted Friday, February 15, 2013 12:04 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, July 11, 2014 1:42 PM
Points: 95, Visits: 603
You are correct, it is security... I issued same statement this time using user id and password to see if it works, and yes it did give me results:

select *
from OPENDATASOURCE('SQLNCLI',
'Data Source=DESTSERVR\INSTANCE;user id =test;password=psw' ).[TESTTBL].dbo.[TBLNAME]

The question I have is that if I am running the query, and my windows account is admin on both boxes, why isn't it working then!?

Thank you.

Lava



Post #1420720
Posted Friday, February 15, 2013 12:05 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, July 11, 2014 1:42 PM
Points: 95, Visits: 603
I said I GOT CONFUSED :) No one said anything :)


Post #1420722
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse