1: Create table #tmp (id int,name varchar(10))
2: Select * into #tmp from 已存在的表

解决方案 »

  1.   

    select * into #temp1 from sysobjectsselect * into ##temp1 from sysobjects
    #局部临时  ##全局
      

  2.   

    我把代码写上来,各位前辈帮我看看错哪儿了:
    select * into ##temp from a join b on a.id=b.id
    其中a是主表,b是明细表,程序报错说是id必须是唯一的,这是什么意思?
      

  3.   

    select a.*,b.* into ##temp from a join b on a.id=b.id
      

  4.   

    我把代码写上来,各位前辈帮我看看错哪儿了:
    select * into ##temp from a join b on a.id=b.id
    其中a是主表,b是明细表,程序报错说是id必须是唯一的,这是什么意思?你上面的将两张表JOIN后得到的记录里有两个字段--ID。所以不唯一
    你把重复的字段--ID去掉一个
    例如:select a.*,b.name,b.sex,b.job,.... into ##temp from a join b on a.id=b.id
    记住,b.id就不要取了,明白吗?