例:
将 11.txt 文件(其内容是:10902003100801
                          10902003100802
                          10902003100803
                          10902003100804
                          10902003100805
                          10902003100806 导入SQL7中TEXT 内的T1 表的POTXT 字段中

解决方案 »

  1.   

    利用sql server的企业管理器,选中要导入的数据库,右键菜单选择-》导入数据-》设置源为文本文件并浏览到你的txt文件,然后依次执行就可以了。关键在最后一步,你要选择导入那个表还是自建表,以及那个字段。这里的技巧你自己体会吧。
      

  2.   

    转贴:
    Function txtToSQLServer(txtfilename: string): boolean;
    var
    adoCon : TADOConnection;
    adoQuery : TADOQuery;
    txtSourceFile : TextFile;
    begin
    result := False;
    if Not FileExists(txtfilename) then exit;
    try
    assignfile(txtSourceFile,txtfilename);
    Reset(txtSourceFile);
    if Eof(txtSourceFile) then exit;
    adoCon := TADOConnection.Create;
    adoQuery := TADOQuery.Create(nil);
    try
    With adoCon do
    begin
         ConnectionString := 'DRIVER={SQL SERVER};SERVER=ERPSERVER;UID=sa;PWD=;Database=TEST';
         Connected := True;
    end;
    With adoQuery do
    begin
         Connection := adoCon;
    end;
    except
          on E:Exception do
               showmessage(E.Message);
    end;
    while not eof(txtSourceFile) do
    begin
           With adoQuery do
           begin
                 sql.clear;
                 sql.add('insert into t1(kqno) values (' + quotedstr(readln(txtSourceFile) + ')');
                 ExecSQL;
           end;
    end;
    result := true;
    finally
           adoCon.close;
           adoQuery.free;
           adoCon.free;
    end;
    end;
      

  3.   

    先用ADO +ADOQUERY 联接,再在ADOQUERY内写几名代码便可例子我已EMAIL给你看看