Solved

OPENDATASOURCE Sometimes fails

Posted on 2010-11-18
9
1,253 Views
Last Modified: 2012-05-10
I have a view created by OPENDATASOURCE.  The view is

SELECT *
FROM OPENDATASOURCE ('SQLNCLI','Data Source = mydatasource;trusted_connection=yes')
.dbname.tablename

Randomly I get the following error when I run a select on the view from my workstation.

Msg 18456, Level 14, State 1, Line 1

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

OLE DB provider "SQLNCLI" for linked server "(null)" returned message "Invalid connection string attribute".

 

If I immediately log into the server and run it there (with no problems) I can jump back to my desktop and run it (almost like I cleaning out some memory or something).

 

So I wanted to see if there was an execution count that would trigger the error.  I ran a loop selecting * from the view for well over an hour on my machine..  The query was executed over 225,000 times.  When it was done, I ran the select statement alone ~5 times with no problems.  I leave my session for a few minutes I come back and get the error again and of course log into the server run it come back…no problems.

 
Any ideas?
0
Comment
Question by:gdspeare
  • 5
  • 4
9 Comments
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 34166370
Try using integrated security like:


SELECT *
FROM OPENDATASOURCE ('SQLNCLI','Data Source = mydatasource;Integrated Security=SSPI')
.dbname.tablename

Open in new window


because you are using trusted connection, anonymous login will always fail.
0
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 34166454
No, use standard security is what I meant, sorry.

Integrated security and trusted connection set to true are the same.

So, should be:

SELECT *
FROM OPENDATASOURCE ('SQLNCLI','Data Source = mydatasource;UserId=Your_Username;Password=Your_Password')
.dbname.tablename
0
 

Author Comment

by:gdspeare
ID: 34167284
why do you think think this would address the ocassional error?  I can run it just fine.  

plus this is going into an app.  users won't be entering any credentials.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 28

Expert Comment

by:sammySeltzer
ID: 34167578
>>plus this is going into an app.  

Web app, you mean? Your original post didn't indicate that.

if it is .net, you may wish to consider adding <impersonate = "True">

>>users won't be entering any credentials.

True. They don't have to because once you create an account on the db useing SQL Server Authentication Mode and add you give it read or execute or whatever permission you wish to give it, and you enter that account into your code as I indicated, then it will authenticate any user accessing the app.

0
 

Author Comment

by:gdspeare
ID: 34167833
what you are suggesting makes sense. However, it doesn't aswer the question of why my query bombs out from my workstation after some event (which i can't identify) and then is successful after I run the query on the server directly.  

I'm also not convinced that I would get the same issue b/c I'm an admin on both boxes.  So if i'm running into this issue a sql specific account would too
0
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 34167881
What I think is happening is that in your iis, you are using windows integrated authentication which means that anyone accessing your app must be a windows domain user.

So, when you log in as an admin, by default, you have sysadmin account and things work fine.

If you try to run without a domain account, you run into the issue you are having.

So, the decision you have to make is whether to allow all users to have domain account OR, you do as I suggested and use ONE SQL Server account that has both execute and and atleast readOnly permission.
0
 

Author Comment

by:gdspeare
ID: 34168160
i'm not using IIS - I'm logged into the server user SSMSE on my workstation and when the query fails I log into a full install on the server.

I haven't integreated the query into the asp app because of this issue.
0
 
LVL 28

Accepted Solution

by:
sammySeltzer earned 500 total points
ID: 34168593
0
 

Author Closing Comment

by:gdspeare
ID: 34168796
not what I was hoping to learn, but it seems like this is my answer.  Thanks.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Database ERD 4 32
SQL Quer 4 23
Where is the Help Section? 8 29
MS SQL function that converts base-10 to base-36 2 7
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

820 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