如何将一个表的某一字段的记录做为另一个表的字段??

解决方案 »

  1.   

    select colname into 目的表 from 原表
    这是个内容复制,条件可以自己加
    select colname into 目的表 from 原表 where 1<>1
    这个结构复制
      

  2.   

    insert into table b select 字段 from table a
      

  3.   

    我的意思是将 select colname from 原表 的结果
    作为 create table colname....
      

  4.   

    select  colname into newtable  from 原表
      

  5.   

    那就得用动态sql了
    declare @sql varchar(8000)
    select @Sql=' Create table ('+colname+' int )' from 原表
    exec(@sql)