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.  

example...

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?

Racin

LVL 3
RacinRanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

M1OneCommented:
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.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cheeky-monkeyCommented:
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.
0
Muhammad Ahmad ImranDatabase DeveloperCommented:
just simple!!

Downloads the utility DB Tools and impot this all.

LeoAhmad
0
RacinRanAuthor Commented:
M1One,

I was hoping not to have to do that.


cheeky-monkey,

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



leoahmad,

Could you post a link?

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.