Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. OpenRowSet - Sql server

OpenRowSet - Sql server

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hum Dum
    wrote on last edited by
    #1

    I am using Openrowset function of sql server to read data from excel files.

    SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=E:\IGM\Files\cis overview.xls;HDR=No;IMEX=1;','SELECT * FROM [CIS Overview$]')

    But all columns are not showed by openrowset. below is just sample, the excel file which i am reading having 28 columns, and 27 having no data in it, just heading, and 28 is ignored by Openrowset.

    col1 col2 col3

    A X
    B X
    C X
    . .
    . .

    Openrowset is not returning col3 in resultset? Its only showing col1, col2. But if i insert some data in col2(any cell), result set will have all three columns. It is ignoring last column if previous has no data? i also include HDR=NO option in query, but no luck? Is their any way to get all columns in result set? any help? regards,

    L 1 Reply Last reply
    0
    • H Hum Dum

      I am using Openrowset function of sql server to read data from excel files.

      SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=E:\IGM\Files\cis overview.xls;HDR=No;IMEX=1;','SELECT * FROM [CIS Overview$]')

      But all columns are not showed by openrowset. below is just sample, the excel file which i am reading having 28 columns, and 27 having no data in it, just heading, and 28 is ignored by Openrowset.

      col1 col2 col3

      A X
      B X
      C X
      . .
      . .

      Openrowset is not returning col3 in resultset? Its only showing col1, col2. But if i insert some data in col2(any cell), result set will have all three columns. It is ignoring last column if previous has no data? i also include HDR=NO option in query, but no luck? Is their any way to get all columns in result set? any help? regards,

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Try putting headers in the first row of the spreadsheet and use HDR=Yes option.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups