dbTalk Databases Forums  

Import of Variable Length Lines With Fixed Length Fields

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Import of Variable Length Lines With Fixed Length Fields in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
SteveW
 
Posts: n/a

Default Import of Variable Length Lines With Fixed Length Fields - 11-17-2003 , 01:26 PM






I'm using a fixed length fields in a DTS package to import a text file.

Each line in the text file ends with a CR\LF delimiter.

The lines do not all have the same length. Blank fields after the end of the last field with data are not filled with any characters - the CR\LF delimiter simply occurs after the last field with data.

The DTS package does not seem to recognizing the CR\LF as a line delimiter when it arrives before all the fields are populated (even though it has been selected as the line delimiter for the package. When a 'short' line is encountered, enough text is stolen from the next record to finish out the 'missing' fixed length fields and the next record is ignored.

Is there a way to get the DTS package to start a new record with each occurrence of the line delimiter, or must I find some way to fill out all the null data fields at the end of each record with spaces or some other character?

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Import of Variable Length Lines With Fixed Length Fields - 11-17-2003 , 02:28 PM






Unfortunately DTS will look at the row you define at design time and then
expect to find rows of that size when you go at run time. If you come
across a short row then it will carry onto the next row to satisfy this
need.

--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"SteveW" <swolf97222 (AT) yahoo (DOT) com> wrote

Quote:
I'm using a fixed length fields in a DTS package to import a text file.

Each line in the text file ends with a CR\LF delimiter.

The lines do not all have the same length. Blank fields after the end of
the last field with data are not filled with any characters - the CR\LF
delimiter simply occurs after the last field with data.
Quote:
The DTS package does not seem to recognizing the CR\LF as a line delimiter
when it arrives before all the fields are populated (even though it has been
selected as the line delimiter for the package. When a 'short' line is
encountered, enough text is stolen from the next record to finish out the
'missing' fixed length fields and the next record is ignored.
Quote:
Is there a way to get the DTS package to start a new record with each
occurrence of the line delimiter, or must I find some way to fill out all
the null data fields at the end of each record with spaces or some other
character?




Reply With Quote
  #3  
Old   
SteveW
 
Posts: n/a

Default Re: Import of Variable Length Lines With Fixed Length Fields - 11-17-2003 , 03:36 PM



So what then is the point of a row delimiter?

Reply With Quote
  #4  
Old   
Darren Green
 
Posts: n/a

Default Re: Import of Variable Length Lines With Fixed Length Fields - 11-18-2003 , 04:50 PM



In article <82B155DC-7816-430A-855E-7607AA2225C3 (AT) microsoft (DOT) com>, SteveW
<anonymous (AT) discussions (DOT) microsoft.com> writes
Quote:
So what then is the point of a row delimiter?
The point is that until you have provided all characters defined in your
fixed width columns you are still "in" a column, so what it actually
does is treat the CrLf as part of the column data. Very useful if you
are importing fixed width data that does have multiple lines per data
value. Not so useful in your case.

Your file is not a valid fixed width format. Unfortunately not everyone
agrees with what is valid, so many systems produce these truncated line
files. Best solution is to parse the file and pad them to correct
length.

I wrote a custom task for this, see the PaddingTask

Archive
(http://www.sqldts.com/Default.aspx?273)

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.