I have a flat file composed by several rows of text, with no field separators (I parse them by position) and with newlines as row separators. Basically, something like this:
FIELD1AFIELD2AFIELD3AFIELD4A...
FIELD1BFIELD2BFIELD3BFIELD4B...
FIELD1CFIELD2CFIELD3CFIELD4C...
I'm bulk-inserting it in a temp table before parsing it to its final table, using this command:
BULK INSERT TEMPTABLE
FROM 'c:\location\file'
WITH (FIELDTERMINATOR= '',ROWTERMINATOR = '\n',MAXERRORS = 0)
Now, the first and last rows serve as header and trailer for the file, and contain special information. As such, they don't follow the same pattern of "FIELD1AFIELD2AFIELD3AFIELD4A...", so I need to take them into account. Furthermore, I need to insert the header row's information in another table specifically.
But when I run the bulk insert, the rows aren't inserted in order in the temporal table, so I can't just assume that the top register will be the header, and the last register the trailer.
Is there a way to force the bulk insert ot follow the order of the rows in the flat file? I don't have a "key column", nor an index, nor anything in the file, and inserting row numbers in this file is impossible (I need to keep it as it was received, and it's too large to copy or modify it anyway).
Thanks