Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Davids_Maguire
Starting Member
14 Posts |
Posted - 2007-10-21 : 13:26:05
|
| dear all, I have a text file that contains data that i need to insert into sql server... the file size is about 800 MB .. and contains about 17,000,000 lines .. some one told me that there is a way in sql server to import this data automatically by writting some scripts ... the file looks like this xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyy .. yyyyy "I Need only These fields (the Ys).. I don't care about the rest of the file"yyyy .. yyyyyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxany help is really appriciated |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-21 : 13:51:10
|
| Sorry, I haven't really understood the problem.There are some xxxx lines. How do you determine those, do they start with something specific, or have a "patten" than can be used to "ignore" them?and what about the "yyy....yyy" lines - do they have multiple columns, delimited by a Comma or something like that? Or just a single Column value?Kristen |
 |
|
|
Davids_Maguire
Starting Member
14 Posts |
Posted - 2007-10-21 : 14:43:26
|
quote: Originally posted by Kristen Sorry, I haven't really understood the problem.There are some xxxx lines. How do you determine those, do they start with something specific, or have a "patten" than can be used to "ignore" them?and what about the "yyy....yyy" lines - do they have multiple columns, delimited by a Comma or something like that? Or just a single Column value?Kristen
the xxxx lines that will be ignored begin with ;for the yyy lines it is just 2 columns seprated by ::also i need to ignore anyother lines that doesn't contain the :: delimiter .. is that possiblei tried the bulk insert method but it gives error if the file ended with any other lines that doesn't contain the delimiter . |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-21 : 15:13:41
|
| "is that possible"I reckon!I would import the file into a table with a single column, big enough to hold the widest lineThen delete anything without the "::" separatorDELETE DFROM MyTable AS DWHERE MyColumn NOT LIKE '%::%'Then split the remaining rows using "::" as the delimiter.Kristen |
 |
|
|
|
|
|
|
|