![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
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. |
#4
| |||
| |||
|
|
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. |
![]() |
| Thread Tools | |
| Display Modes | |
| |