Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

Importing a fixed-width text file

I have a variable length fixed-width text file.  I am transferring this file from a mainframe via ftp using sdi32 within a DTS package.

The file has as it's last field a 1 char indicator.  If this indicator is blank the file contains the crlf in the position of the last field instead of after the position of the last field.  If this short record is the first record in the file then sql incorrectly determines this to be the end of the record position for all the records.  


190002669565199706149910    C00000000000000000000000000000PPH                        9920      TEMPORARY EMPLOYEES 01NT04200000950000000 Y00000000000VT19970815        NNNSO00000NRCY00100--End of record 1

190002669565199612279910    C00000000000000000000000000000PPH                        9920      TEMPORARY EMPLOYEES 01NC04200000950000000 Y00000000000VT19970110        NNNAC00000NRCY00100N--End of record 2

As a work-around I use Access as a middleware translator because Access correctly determines the length of the record.  I would like to get away from using Access as a translator.  

I researched awhile ago and this was a documented problem from Microsoft.  

My question is:  Is there a fix for this or some other cleaner way to import this file?


1 Solution
DTS also allows to write code (VBScript) to process records one by one. That way you will be able to write conditions, check end of file/line characters and process each row accordingly.

What a %#@^! that is! You could always create a DTS job as normal, but instead of running it, save it as a Visual Basic File. You can then open the file and edit the column length for the last column to be one more than length that the DTS job create. Then you just run the DTS VB file as per usual.
Muhammad Ahmad ImranDatabase DeveloperCommented:
just simple!!

Downloads the utility DB Tools and impot this all.

RacinRanAuthor Commented:

I was hoping not to have to do that.


No kidding.  :)   I tried your suggestion ... but it still throws the subsequent records because it then interprets the crlf that is positioned incorrectly.


Could you post a link?


Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now