1

I am running the following query to import a csv file:

SELECT * FROM OPENROWSET('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=D:\Documents\;', 'SELECT * from file.csv') AS something

I am getting this error:

OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".

This is what I have done to try an resolve the issue, neither of which was enough:

  1. MsSQL and IIS have access to the folder and file in question. They also both have access to the temporary folder for Network Services under which SQL server is running.
  2. I have enabled Ad Hoc Distributed Queries using sp_configure
  3. I have fixed the registry key DisallowAdhocAccess by setting it to 0
  4. I have installed Microsoft Access Database Engine 2010 Redistributable

The system is a Windows 2008 Server running SQL Server 2012 Express, but the issue has been replicated with SQL Server 2008 as well.

At this point any random ideas are appreciated :). Thanks!

4
  • Are you enabled Ad Hoc DISTRIBUTED Queries? Jan 5, 2013 at 14:04
  • Yes indeed. I've added the clarification to my post...
    – Aron
    Jan 5, 2013 at 16:24
  • If you try looking with process monitor does it even try and open the file? If so does that give any errors? Jan 6, 2013 at 0:11
  • Does this help? stackoverflow.com/a/7476211/1073631
    – sgeddes
    Jan 6, 2013 at 0:46

2 Answers 2

2

The answer turned out to be quite simple, but very much underdocumented: the MSDASQL driver did not work together well with a 64bit installation of SQL Server.

There is some more info about this in this thread but for my purposes, "downgrading" to a 32bit instance was a sufficient solution.

1

It Works. Just make sure tha name of the driver is EXACTLY as it shows in control panel ODBC Data Sources (64 bits). In my case, the correct name is "'Driver={Microsoft Access Text Driver (*.txt, *.csv)}", I use it in my machine with Windows 8.1 64 bits.

Regards,

MarianoC.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.