Select into Excel with OPENROWSET Error

  • Tried the following to export some data to excel:

    INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:test.xls', 'SELECT * FROM [Sheet1$]')

    SELECT * FROM Test_Info

    I get this error error:

    Msg 213, Level 16, State 1, Line 8

    Insert Error: Column name or number of supplied values does not match table definition.

    The excel is blank, is this error because there are no column names in the execl?

    Is there a way to put the cloumn name in the spreadsheet dynamicly?

    Thanks

  • May I suggest reading the following

    http://www.simple-talk.com/sql/t-sql-programming/sql-server-excel-workbench/

    It has all that you want to know about interfacing with EXCEL and more, great sample code.

    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]

  • Thanks, I think that I can find what I need here. This is a very comprehensive article!

    Good Stuff

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

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