Sql-server – SQL Server OPENROWSET OLE DB provider “MSDASQL” for linked server “(null)”

openrowsetsql server

First I configure ad hoc distributed queries with this query:

EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO

SELECT * FROM
OPENROWSET('MSDASQL'
 ,'Driver={Microsoft Access Text Driver (.txt, .csv)}; 
 DefaultDir=C:\CSV' 
 ,'select * from smdr.csv') T

then when I try to execute the above script I get 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)".

How can I fix this?

Best Answer

This issue has been solved. here is details.

SELECT * FROM OPENROWSET ('Microsoft.ACE.OLEDB.12.0', 'Text;Database=C:\CSV; ', 'SELECT * FROM smdr.csv')

ERROR: Msg 7403, Level 16, State 1, Line 31 The OLE DB provider "Microsoft.ACE.OLEDB.12.0" has not been registered. FIX = INSTALL "AccessDatabaseEngine_x64.exe"


EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1 GO EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1 GO


OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Unspecified error". Msg 7303, Level 16, State 1, Line 47 Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)". FIX = EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 0 GO --Alternately In Sql Management Studio go to Server Objects - Linked servers - Providers - Microsoft.Jet.OLEDB.4.0 then Options and Uncheck "Allow Inprocess". FIX = Add “-g512;” to the front of the value for parameter “Startup Parameters”.


Msg 7399, Level 16, State 1, Line 57 The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error. Access denied. Msg 7350, Level 16, State 2, Line 57 Cannot get the column information from OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)". FIX = Change SQL Server Data Engine Account from "NT Service\MSSQLServer" to a Domain Account with access