Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012
    Posts
    3

    Unanswered: Can I import a .txt file by string start/end position

    I'm trying to import a large .txt file into SQL but a regular bulk insert will not do as there are no delimiters. Each line contains roughly 1080 bytes of data that are scrunched together. (1 byte - represents one character) The only thing I know for sure is the start and end position for each column entry which is fixed-format. For example:

    col1 (1,3)
    col2 (4,6)
    col3 (7,7)
    col4 (8,30)
    col5 (31,39)
    ...
    colN (1050, 1080)

    This occurs for X,XXX,XXX rows. So for each row, I want to pull in the column info based on the string position of the data.

    How can I do this in SQL? All I have found so far is bulk insert entry...

    Thanks!

  2. #2
    Join Date
    Aug 2004
    Location
    Dallas, Texas
    Posts
    831
    Try SSIS packages. There is a flat file (source) task that might do the trick.
    Quote Originally Posted by econgirl8 View Post
    I'm trying to import a large .txt file into SQL but a regular bulk insert will not do as there are no delimiters. Each line contains roughly 1080 bytes of data that are scrunched together. (1 byte - represents one character) The only thing I know for sure is the start and end position for each column entry which is fixed-format. For example:

    col1 (1,3)
    col2 (4,6)
    col3 (7,7)
    col4 (8,30)
    col5 (31,39)
    ...
    colN (1050, 1080)

    This occurs for X,XXX,XXX rows. So for each row, I want to pull in the column info based on the string position of the data.

    How can I do this in SQL? All I have found so far is bulk insert entry...

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •