Column Ordinal Position changed in OpenRowSet

  • I have a table in an Access db that I am trying to import. The filename, data, and location is going to change, the table name will not. I have some T-SQL that writes the following:

    
    
    SELECT * into db.dbo.[BloodType] FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','C:\path\Blood.mdb';'admin';'', Data)

    The table Data has the following field names:

    zBLOOD_TYP_GRP_CD

    BTABOGDOM_DESC_TX

    RowStatus

    RowModified

    RowInitials

    RowSourceName

    RowAdded

    After the previous code is run db.dbo.[BloodType] has the fields in the following order:

    [BTABOGDOM_DESC_TX]

    [RowAdded]

    [RowInitials]

    [RowModified]

    [RowSourceName]

    [RowStatus]

    [zBLOOD_TYP_GRP_CD]

    I need the table to have the orginal ordinal positions for the columns. Has anybody seen this before? If so, how can I fix it?

    Thank you in advance,

    Richard Binnington

  • Replace the * with the actual column names.

    Select [zBLOOD_TYP_GRP_CD],

    [BTABOGDOM_DESC_TX] ......

  • This is a file being uploaded by a user. I co not know what the field names are going to be.

    A more complete solution for me actually would be to somehow grab the first table (non-system) in the Access database, but I am not sure how I can do that.

    Any guidance would be appreciated.

    Thanks,

    Richard

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

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