Click here to Skip to main content
15,885,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Everyone,

I am using following query to export output of query to an excel file.

SQL
insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0',
    'Excel 8.0;Database=C:\Projects\Book1.xls;',
    'select * from [sheet1$]') SELECT N_APP_DESCRIPTION FROM N_APP_APPLICATION


Here i am trying to export only one field of table in Excel sheet. But it comes up with following error.


Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" 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 "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".

I have gone through several links where it says to make sure file name is correct and i ensure that file name is correct.


I have used following link to do this

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926[^]

SQL
Create an Excel file named testing having the headers same as that of table columns and use these queries

1 Export data to existing EXCEL file from SQL Server table
insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0',
    'Excel 8.0;Database=D:\testing.xls;',
    'SELECT * FROM [SheetName$]') select * from SQLServerTable



As said in link i have created "N_APP_DESCRIPTION" column in excel sheet i.e on sheet1

Please help me if you can


Thanks alot
Posted
Comments
Maciej Los 29-Mar-13 3:34am    
We need more information:
- does sql server is installed locally (enables network connections?) or in network?
- does machine is on 32/64 bit OS?
- does sql server is on 32/64 bit OS?
deepakdynamite 29-Mar-13 4:11am    
sql server is installed on another server. and i am connected using management studio.
My machine is 34 bit OS
Maciej Los 29-Mar-13 4:38am    
...and server: 32 or 64 bit version?
deepakdynamite 29-Mar-13 9:09am    
Thanks Alot.... Your Question itself solved my problem..

The reason of failure was as under :

I was connected through remote machine and server didn't have excel file on path. Conclusion is path provided should be of server file directory

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900