有文本1.txt
735:    11:   180:        22:   12676:
805:     7:   180:        22:   12347:
133:    54:   180:        22:   12676:
857:     7:   180:        22:   12676:
805:    32:    60:        20:   12008:
542:   122:   180:        60:   12754:
129:   118:   180:        22:   12676:
909:    51:   180:        22:   12676:
希望取第一列,第二列和第四列,保存为2.txt
735:    11:      22:
805:     7:      22:
133:    54:      22:
857:     7:      22:
805:    32:      20:
542:   122:      60:
129:   118:      22:
909:    51:      22:
而且不能出现
735:     11:       180: 
805:     7:       180:  
133:     54:       180: 
857:     7:       180:  
805:     32:       60:  
542:     122:       180:
129:     118:       180:
909:     51:       180: 
如何实现,请大侠指点!

解决方案 »

  1.   

    可以先导到sql server 在导出成txt
    再倒入sql server 的时候,把不要的列去掉
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      t:TStringList;
      temp:TStringList;
      t1:TStringList;
      i:integer;
    begin
      t:= TStringList.Create;
      t1:=TStringList.Create;
      temp:=TStringList.Create;
      temp.Delimiter:=':';
      t.LoadFromFile('e:\temp\1.txt');
      for i:=0 to t.Count-1 do
      begin
        temp.DelimitedText:=t.Strings[i];
        t1.Add(Format('%s:%8s:%8s:',[temp[0],temp[1],temp[3]]));
      end;
     t1.SaveToFile('e:\temp\2.txt');
     t.Free;
     t1.Free;
     temp.Free;
    end;