Bulk Insert of Fixed Length Text File?

  • I need to import a fixed length text file into a sql table. The columns will always have the same positions, but there is not a column delimiter. Should I use bulk insert? Is there a good example of doing this?

    Thank you

  • Sample data should have been helped us to help you..

    any way, if the data is Continuous (with no spaces or no delimiters), you can use still bulkinsert to dump into a staging table first into one column then transferring the data to final table with splitting.

    BULK INSERT AdventureWorks.Sales.SalesOrderDetail

    FROM 'f:\orders\lineitem.tbl'

    WITH

    (

    FIELDTERMINATOR =' |',

    ROWTERMINATOR =' | '

    )

  • You can define columns as fixed width for OpenRowset. If you use that, it's pretty easy to bulk import fixed-width text.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

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

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