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 |
|
yeahbuddy
Starting Member
8 Posts |
Posted - 2007-04-11 : 15:35:32
|
| I am doing a bulk insert on files that have spaces as the field terminator and '\n' as the row terminator. The problem I am having is that some of the files include an extra space after the last field before it does the newline. I need to be able to handle this whether or not that extra space is there without writing to the db those spaces on the end of that last field. Any solutions? |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-04-11 : 16:03:32
|
| use a different delimiter.************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
yeahbuddy
Starting Member
8 Posts |
Posted - 2007-04-11 : 17:08:41
|
| These are the files I have to work with. The delimeter is spaces. |
 |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-04-11 : 17:26:18
|
| Not sure what else you can do. You can Bulk insert the data into a new table that has an extra column. since there is no value at the end of the file, you will prbly end up with a blank column. Then you can do an INSERT INTO yourOriginalTable <columms>SELECT <columns> FROM theNewTable************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2007-04-11 : 19:01:57
|
what method are you using to import these files into sql, If the trailing spaces before the \n is the only issue simply do a find and replace via a text editor changing the spaces.i.e. If you want there only to be 5 spaces but certain lines have 6 do this so the file is uniform.I am using a "_" to represent a space in the following illustration since this forum automatically removes multiple spaces.FIND "______\n"REPLACE ALL "_____\n"Or if you are saying that post importing into a sql table you do not want the spaces included as part of that field just do a.update mytableset lastcolumn = rtrim(lastcolumn) to your table. |
 |
|
|
|
|
|