insert into Tb1(Col1,Col2)
  select ColA,ColA from Tb2

解决方案 »

  1.   

    --太久不写了,玩。
    declare @e varchar(8000)select @e=''select  @e =@e+c1.name+','
    from syscolumns  c1,syscolumns c2
    where  c1.id=object_id('table1') and  c2.id=object_id('table2')
        and c1.name=c2.nameselect @e=case when len(@e)>0  then left(@e,len(@e)-1) end
    select @e='insert into table1 ('+@e+') select '+@e+' from table2'
    exec (@e)
     
    --如果还要注意什么不为空之类的区别,自己研究系统表
      

  2.   

    select top 0 col1,col2,col3... into tab from table1col1,col2,col3...為你要選擇的字段
      

  3.   

    1.建立新表select col1,col2,col3,....into newtable form oldtable where ......2.insert into newtable col1,col2,col3,....select col1,col2,col3,....from oldtable where...
      

  4.   

    --插入一张新表
    select col1,col2,col3,....into newtable from oldtable where 条件--插入到已有的表中
    insert newtable(col1,col2,col3,....) 
    select col1,col2,col3,....from oldtable 
    where 条件
      

  5.   

    insert into newtable col1,col2,col3,....select col1,col2,col3,....from oldtable where...