Export Query result to Excel Sheet

  • 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.

  • 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[/url]
    Before posting a performance problem please read[/url]

  • 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.

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply