用insert into Table1 select * from T2 ?

解决方案 »

  1.   

    insert into Table1(......) 
    select cloumn1,cloumn2...
    from Table2 as b
    where b.Code_No not in(select Code_No from Table1)
      

  2.   

    要两个表的结构是一样的,先把表1的数据读出来,然后全添加到表2中哟
    sql1="select * from 表1"
    rs1.open sql1 ,con,1,3
    sql="select * from 表2"
    rs.open sql ,con,1,3
    do while(not rs.eof)
    rs1.addnew
    rs1("a")=rs("a")
    ...
    rs1.update
    rs.movenext
    loop
    rs.close
    rs1.close
      

  3.   

    with dm.Qfee do
        begin
          close;
          sql.Clear;
          sql.Add('delete from fee_temp');
          execsql;
    //-----------------------------------------清空fee_temp表-----------------
          close;
          sql.Clear;
          sql.Add('insert into fee_temp ');
          sql.Add('select * from fee where (Pay_Is=true) and (Pay_Acman='''+op+''') and (Pay_Date>=:ss) and (Pay_Date<=:ee)');
          parameters[0].Value:=timestart;
          parameters[1].Value:=timeend;
          execsql;
    //-----------------------------------------从fee中选取记录-----------------
          close;
          sql.Clear;
          sql.Add('insert into fee_temp ');
          sql.Add('select * from fee_month where (Pay_Is=true) and (Pay_Acman='''+op+''') and (Pay_Date>=:ss) and (Pay_Date<=:ee)');
          parameters[0].Value:=timestart;
          parameters[1].Value:=timeend;
          execsql;
    //------------------------------------------从fee_month中选取记录-----------
          close;
          sql.Clear;
          sql.Add('select * from fee_temp');
          open;
        end;//with dm.Qfee
    with dm.Qyh do
      begin
        close;
        sql.Clear;
        sql.Add('select count(Yh_ID),sum(ele),sum(ele_Fee),sum(Late_Fee),sum(Sum_Fee) from fee_temp');
        open;
      end;
      

  4.   

    with dm.Qfee do
        begin
          close;
          sql.Clear;
          sql.Add('delete from fee_temp');
          execsql;
    //-----------------------------------------清空fee_temp表-----------------
          close;
          sql.Clear;
          sql.Add('insert into fee_temp ');
          sql.Add('select * from fee where (Pay_Is=true) and (Pay_Acman='''+op+''') and (Pay_Date>=:ss) and (Pay_Date<=:ee)');
          parameters[0].Value:=timestart;
          parameters[1].Value:=timeend;
          execsql;
    //-----------------------------------------从fee中选取记录-----------------
          close;
          sql.Clear;
          sql.Add('insert into fee_temp ');
          sql.Add('select * from fee_month where (Pay_Is=true) and (Pay_Acman='''+op+''') and (Pay_Date>=:ss) and (Pay_Date<=:ee)');
          parameters[0].Value:=timestart;
          parameters[1].Value:=timeend;
          execsql;
    //------------------------------------------从fee_month中选取记录-----------
          close;
          sql.Clear;
          sql.Add('select * from fee_temp');
          open;
        end;//with dm.Qfee
    with dm.Qyh do
      begin
        close;
        sql.Clear;
        sql.Add('select count(Yh_ID),sum(ele),sum(ele_Fee),sum(Late_Fee),sum(Sum_Fee) from fee_temp');
        open;
      end;