MS SQL openrowset function

Posted on 2015-02-03
Last Modified: 2015-02-07
I tried to run this command, and am getting the error message. How can I solve it
'Excel 12.0;Database=C:\autre\testing.xls;',
'SELECT * FROM [Sheet1$]')
SELECT * FROM dbo.contract Where PROJECTID=160

Msg 15281, Level 16, State 1, Line 1
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server.
 A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure.
Question by:Omer-Pitou
  • 2
  • 2
LVL 12

Accepted Solution

Habib Pourfard earned 250 total points
ID: 40587265
try this:
sp_configure 'show advanced options', 1;
sp_configure 'Ad Hoc Distributed Queries', 1;

Open in new window


Author Comment

ID: 40587362
The configuration works perfectly. But, now i am getting this error message
Cannot create an instance of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 250 total points
ID: 40587490
Seems like the sql server machine is missing "Microsoft Access Database Engine 2010 Redistributable”

Author Comment

ID: 40588940
Am I right by saying that the number 12  in "Microsoft.ACE.OLEDB.12.0" refers to 2010 version of this engine?
What If I have access 2013 installed on my computer, what you will be the version number of the engine?
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 40589017
>Am I right by saying that the number 12  in "Microsoft.ACE.OLEDB.12.0" refers to 2010 version of this engine?
Yup , you can download it from here 

>What If I have access 2013 installed on my computer, what you will be the version number of the engine
2013 is 14.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

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now