dbTalk Databases Forums  

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

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


Discuss When importing text file, order of lines are all messed up in the microsoft.public.sqlserver.dts forum.



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

Default When importing text file, order of lines are all messed up - 04-29-2005 , 04:36 PM






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
appreciated.

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

Default Re: When importing text file, order of lines are all messed up - 04-30-2005 , 01:15 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


"pelican" <pelican (AT) discussions (DOT) microsoft.com> wrote

Quote:
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
appreciated.



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

Default Re: When importing text file, order of lines are all messed up - 05-02-2005 , 08:44 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.


"Allan Mitchell" wrote:

Quote:
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


"pelican" <pelican (AT) discussions (DOT) microsoft.com> wrote

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
appreciated.




Reply With Quote
  #4  
Old   
pelican
 
Posts: n/a

Default Re: When importing text file, order of lines are all messed up - 05-02-2005 , 09:10 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.

"pelican" wrote:

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


"Allan Mitchell" wrote:

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


"pelican" <pelican (AT) discussions (DOT) microsoft.com> wrote

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
appreciated.




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.