数据结构a表ganame         tel                    city1         city2
某某公司       010-88888888           北京          上海B表city=中国所有地级市城市名大约500条数据
赣州
北京
上海
广州
.
.
.
要求:
批量添加city2效果:
ganame         tel                    city1         city2
某某公司       010-88888888           北京          上海
某某公司       010-88888888           北京          广州
某某公司       010-88888888           北京          赣州意思也就是
批量把b表city导入A表的city2  
a表的其他数据是通过form输入因为一下要添加500条,所有最好考虑效率问题
谢谢

解决方案 »

  1.   

    a表的其他字段数据是通过form输入
      

  2.   

    1、说明:复制表(只复制结构,源表名:a 新表名:b) (Access可用) 
    法一:select * into b from a where 1 <>1 
    法二:select top 0 * into b from a 2、说明:拷贝表(拷贝数据,源表名:a 目标表名:b) (Access可用) 
    insert into b(a, b, c) select d,e,f from a; 3、说明:跨数据库之间表的拷贝(具体数据使用绝对路径) (Access可用) 
    insert into b(a, b, c) select d,e,f from b in ‘具体数据库’ where 条件 
    例子:..from b in '"&Server.MapPath(".")&"\data.mdb" &"' where.. 
      

  3.   

    ??
    insert a 
    select ganame,gel,city1,b.city from a,b
      

  4.   

    insert a(city2)
    select city
    from b
      

  5.   

    insert a(ganame,tel,city1,city2 )
    select '某某公司', '010-88888888','北京',city
    from a,b
    where city='中国'
      

  6.   


    insert a(ganame,tel,city1,city2 )
    select '某某公司', '010-88888888','北京',city
    from b
    where city='中国'
      

  7.   

    a表的其他字段数据是通过form输入
      

  8.   

    意思也就是 
    批量把b表city导入A表的city2  
    b表city有 多少条
    a表就生成多少条,其他数据是通过form输入
      

  9.   

    insert a
    select distinct a.*,b.city2
    from a,b
      

  10.   

    insert into a(ganame,tel,city1,city2) select '某某公司','010-88888888','北京',b.city from b
      

  11.   

    insert into a
    select a.*,b.city from a,b
      

  12.   


    declare  @a table(
    ganame varchar(100),
    tel varchar(100),
    city1 varchar(50),
    city2 varchar(50)
    )
    insert into @a 
    select '某某公司','010-88888888','北京','上海'
    union all
    select '某某公司2','010-88888889','北京','上海'
    declare @b table (
    city varchar(50)
    )
    insert into @b
    select '赣州'
    union all
    select '北京'
    union all
    select '上海'
    union all
    select '广州'
    insert into @a(ganame,tel,city1,city2)
    select distinct ganame,tel,city1,city from @a
    cross join @b
    where city2<>city
    select * from @a order by ganame/*
    ganame tel city1 city2
    某某公司 010-88888888 北京 北京
    某某公司 010-88888888 北京 赣州
    某某公司 010-88888888 北京 广州
    某某公司 010-88888888 北京 上海
    某某公司2 010-88888889 北京 上海
    某某公司2 010-88888889 北京 北京
    某某公司2 010-88888889 北京 赣州
    某某公司2 010-88888889 北京 广州
    */
      

  13.   

    据结构 a表 ganame        tel                    city1        city2 
    某某公司      010-88888888          北京          上海 B表 city=中国所有地级市城市名大约500条数据 
    赣州 
    北京 
    上海 
    广州 



    要求: 
    批量添加city2 效果: 
    ganame        tel                    city1        city2 
    某某公司      010-88888888          北京          上海 
    某某公司      010-88888888          北京          广州 
    某某公司      010-88888888          北京          赣州 意思也就是 
    批量把b表city导入A表的city2  
    a表的其他数据是通过form输入 因为一下要添加500条,所有最好考虑效率问题 insert into 表1(城市) select 城市 from @A
      

  14.   

    select '某某公司','010-88888888' ,'北京',city  
    insert into a (ganame ,tel, city1,city2 )
    from b