SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SELECT from OPENDATASOURCE error


SELECT from OPENDATASOURCE error

Author
Message
lsalih
lsalih
Mr or Mrs. 500
Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)

Group: General Forum Members
Points: 504 Visits: 1051
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



Orlando Colamatteo
Orlando Colamatteo
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15049 Visits: 14396
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
lsalih
lsalih
Mr or Mrs. 500
Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)

Group: General Forum Members
Points: 504 Visits: 1051
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...



Orlando Colamatteo
Orlando Colamatteo
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15049 Visits: 14396
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
lsalih
lsalih
Mr or Mrs. 500
Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)

Group: General Forum Members
Points: 504 Visits: 1051
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



Orlando Colamatteo
Orlando Colamatteo
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15049 Visits: 14396
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
lsalih
lsalih
Mr or Mrs. 500
Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)

Group: General Forum Members
Points: 504 Visits: 1051
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.



Orlando Colamatteo
Orlando Colamatteo
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15049 Visits: 14396
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
lsalih
lsalih
Mr or Mrs. 500
Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)

Group: General Forum Members
Points: 504 Visits: 1051
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



lsalih
lsalih
Mr or Mrs. 500
Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)Mr or Mrs. 500 (504 reputation)

Group: General Forum Members
Points: 504 Visits: 1051
I said I GOT CONFUSED Smile No one said anything Smile



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search