insert tb() select 'asd',col from tbs

解决方案 »

  1.   

    if object_id('tbs') is not null drop table tbs
    go
    if object_id('tb') is not null drop table tb
    go
    create table tbs(Id int ,Num varchar(10))
    insert tbs select 1,'1.0'
    insert tbs select 2,'15.23'
    create table tb(Id int ,Num varchar(10))
    insert tb(ID ,num) select 10,num from tbs
    select * from tb/*
    Id          Num        
    ----------- ---------- 
    10          1.0
    10          15.23(影響 2 個資料列)
    */
      

  2.   

    insert into tb(bb)
    select bb from tbs
      

  3.   

    insert into tb(bb,cc,dd) 
    select bb,'cc','dd' from tbs
      

  4.   


    INSERT INTO TABLEA(A,B,C)
    SELECT "aa","BB", hh FROM TABLEB
     "aa","BB" 为常量, hh 是从TABLEB 查出来的,
    你看呢?