• Register
0 votes


I need to import multiple files with a varying number of columns into SQL Server through a script. I am trying to use OPENROWSET for this. I have done the following.

  1. Installed driver on the client X64 PC.

  2. Execute below commands.

EXEC sp_configure 'show advanced options', 1;
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;

When trying to read the file through

SELECT * from OpenRowset('MSDASQL','Driver={Microsoft Text Driver (*.txt;*.csv)};DefaultDir=c:\Delme\;','select * from input.csv' )

I am getting the following errors.

Msg 7399, Level 16, State 1, Line 17 The OLE DB provider "MSDASQL" for linked server "(null)" reported an error. The provider did not give any information about the error. Msg 7303, Level 16, State 1, Line 17 Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".

43.9k points

Please log in or register to answer this question.

1 Answer

0 votes


Check in ODBC Data Source Administrator that the name of your driver is correctly written in your OpenRowset call. If you're using Microsoft Text Driver it's likely that the name is actually

Microsoft Text Driver (*.txt; *.csv)

Note that this name has a space after the semicolon.

Personally, I don't have Microsoft Text Driver - I have Microsoft Access Text Driver and have to specify it as

Microsoft Access Text Driver (*.txt, *.csv)
50.7k points