Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Export Query result to Excel Sheet Expand / Collapse
Author
Message
Posted Thursday, August 13, 2009 7:10 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, November 23, 2009 9:34 PM
Points: 68, Visits: 64
Hi all,

I am trying to Export query result to Excel sheet it gives error.

Code :

USE DBNAME
GO
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO


INSERT INTO OPENROWSET ('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=c:\Citys\city.xls;','SELECT city_id,city,state_Id,state FROM [Sheet1$]')
SELECT City_id,City,state_Id,(Select State From State Where state_id=S.state_id) AS state
from city S where status_ind='A'
AND city NOT IN (Select city from LatestZipcodes)


It gives error message like:

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

pls help me.
Post #770119
Posted Thursday, August 13, 2009 8:09 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:05 PM
Points: 5,472, Visits: 23,551
If you are NOT using Excel 2007 read the following ariticle which also has sample code.
http://www.simple-talk.com/sql/t-sql-programming/sql-server-excel-workbench/

10:09 - spelling correction


If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Post #770181
Posted Thursday, January 16, 2014 3:05 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 8:44 AM
Points: 1,629, Visits: 2,038
bitbucket-25253 (8/13/2009)
If you are NOT using Excel 2007 read the following ariticle which also has sample code.
http://www.simple-talk.com/sql/t-sql-programming/sql-server-excel-workbench/

10:09 - spelling correction


Bless you Ron! This has solved an issue I was having as well.


Please don't go. The drones need you. They look up to you.
Connect to me on LinkedIn
Post #1531838
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse