Pumping Text File - Row Order Changes -
08-12-2005
, 01:58 AM
Hi:
I've noticed a strange behaviour in my DTS package. I'm pumping from a
text file that has 3 separate sections, only one of which I need (the
middle one). So after the pump I run an SQL task that looks for the
first row of the middle section, and then looks for the last row of the
middle section (the row before the middle section has a header "Start
Part 2" and then row after the middle section has "End Part 2". These
text values come through as field values in the first column.
So what I do is set a counter value in a 'counter_field' column in the
SQL Task after the pump. I then look for the first and last record I
need and then tell it to delete anything before the first record, and
anything after the last. The assumes that the records are read in in
the same order they are in the text file. But for some reason the
values are pumped in one of two ways:
1. In the same order they are in in the text file (rows 1 - 269). i.e
correctly
2. Rows 145 - 269 on top, followed by rows 1 - 144. (??!!?)
So if the first record I need is at row 29 in the text file and the
last record is at position 163 in the text file, in the latter scenario
my counter ends up assigning counter value 153 to the first row and
counter value 18 to the last row.
So my delete would run like this:
DELETE FROM a_table WHERE counter_field < 153 or counter_field > 18
....thereby deleting everything.
Does anyone know why this might happen? I tried creating a simple text
package that did nothing but pump this file into a SQL Server table and
same result--sometimes in order, sometimes bottom half first, top half
second.
FYI, I am reading only the first 5 columns (of more) from the text file
into the first five columns (of 7) of my SQL Server table.
Thanks,
Kayda |