all groups > sql server dts > april 2005 >
You're in the

sql server dts

group:

When importing text file, order of lines are all messed up


When importing text file, order of lines are all messed up pelican
4/29/2005 2:36:01 PM
sql server dts:
Hello everyone,
I am using the "import" function in SQL to import a big text file to SQL.
It will import all the lines, except that starting from line 989, it just to
a line way down at the bottom of the text file, line 70987. Isn't it
strange? I thought the import function will read from top to bottom one line
after anther line. The order of lines in this text file is very important to
me, as each record has 40 or 50 lines. When the order is not right, I would
not know which line goes with which record. Any help will be greatly
Re: When importing text file, order of lines are all messed up Allan Mitchell
4/30/2005 12:00:00 AM
How are you determining that they are not in order?

As far as I know a text file is read top to bottom and left to right. When you retrieve the rows however if you want them in a
particular order then you must use an ORDER BY clause.

Is there anything on which you can ORDER?

If not you may want to add an IDENTITY column.

--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.SQLIS.com - SQL Server 2005 Integration Services.
www.Konesans.com


[quoted text, click to view]

Re: When importing text file, order of lines are all messed up pelican
5/2/2005 6:44:06 AM
I did try adding an identity column and let it increament like an autonumber
in the destination file. But it did not work. When I transfered from the
text file, I got an error message saying that the I did not supply data for
the identiry column, which did not make sense, as SQL was supposed to do that
for me.

The order I mean is when text file was extracted, it looked like this:

RecordNumber: 123456
Title: aaaaa
Year: bbbbb
end of record sign

RecordNumber: 234567
Title: bbbbbbb
Year: ccccccc

End of record sign

.......

This goes on for about a thousand times which I means I have a thousand
records. The order is very important. I would like to read into the SQL the
order the text file list records, and use End of record sign to start a new
record. When the order of the line is or the same as the text file, the wrong
year will be listed for the wrong record, and so is the title. This happened
when I transferfed the text file.

I just don't get it why SQL will not tranfer according to the order the text
file lists records.

Any idea?
Thanks.


[quoted text, click to view]
Re: When importing text file, order of lines are all messed up pelican
5/2/2005 7:10:15 AM
Allan,
I just want to add one thing, when I imported the text file without the
identity column (key), SQL allowed null line to be imported.

Thanks.

[quoted text, click to view]
AddThis Social Bookmark Button