Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Reading/Writing to Excel/CSV files - x64

Author  Topic 

DBA in the making
Aged Yak Warrior

638 Posts

Posted - 2012-03-05 : 18:34:17
I was wondering if there's a way to read and write to Excel/CSV files using something like:

SELECT * FROM
OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=c:\file.xls;',
'SELECT * FROM [data$]')
or

SELECT *
FROM OPENROWSET('MSDASQL',
'Driver={Microsoft Text Driver (*.txt; *.csv)};
DefaultDir=C:\;', 'SELECT * FROM data.csv')


This works on a 32 server, but not on a 64 bit server. I tried installing 64-bit MSDASQL for Windows 2003, but when I run the above code I get the errors:

The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered.

and...

Msg 7399, Level 16, State 1, Line 1
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 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".


------------------------------------------------------------------------------------
Any and all code contained within this post comes with a 100% money back guarantee.
   

- Advertisement -