有A,B 两张表
A: ml(门类) mc(名称)nf(年份)
B:ml(门类) mc(名称)
现要A根据B插入数据ml,mc.且插入行的nf是2010年。怎么写?

解决方案 »

  1.   

    insert a(ml,mc,nf)
    select ml,mc,'2010' from b
      

  2.   

    insert into A 
    Select ml,mc,2010 from B
      

  3.   

    insert a(ml,mc,nf)
    select ml,mc,'2010' from b
      

  4.   

    insert into
      a(ml,mc,nf)
    select
      ml,mc,'2010' 
    from 
      b
      

  5.   

    insert a(ml,mc,nf) 
    select ml,mc,'2010' from b
      

  6.   


    insert into a(ml,mc,nf)select ml,mc,'2010' from b
      

  7.   


    -->sinpoal
    --->利用子查询将数据插入表中
    insert into table1Select ml,mc,2010
     from table2 
      

  8.   

    if(object_id('A') > 0)
      drop table A
    go
    create table A(
    ml varchar(100),mc varchar(100),nf datetime
    )
    insert into A 
    select 'A','A','2009-10-01'
    union all select 'B','B','2010-1-1'
    union all select 'C','C','2010-1-2'
    if(object_id('B') > 0)
      drop table B
    go
    create table B(
     ml varchar(100),mc varchar(100)
    )
    insert into B
    select ml,mc from A where datepart(yyyy,nf) = 2010
    select * from B
      

  9.   

     
    insert into a(ml,mc,)select ml,mc from b 
    然后修改表a nf 列的默认值为2010
      

  10.   

    insert a(ml,mc,nf)
    select ml,mc,'2010' from b