我想创建一个临时表,用sql语句实现,请大家帮忙!!
表结构和默认值如下:#temp22:pid  pro   dianxin  wantong  qita
11   广东      0        0       0
27   山东      0        0       0
36   陕西      0        0       0
40   安徽      0        0       0
55   海南      0        0       0
65   广东      0        0       0另外前面的pid和pro来自另外一张表#temp33:pid  pro 
11   广东
27   山东
36   陕西
40   安徽
55   海南
65   广东

解决方案 »

  1.   

    大哥,这应该够清楚的吧。就是建立一张表啊,字段和默认值都有。,不过就是前面两个字段来自另外一张表,我就不知道怎么写了,然后设置默认值我也不会!。。用sql语句。
      

  2.   

    create table #temp22
    (
      pid int not null,
      pro nvarchar(10) not null,
      dianxin int null,
      wantong int null,
      qita int null
    )
    goinsert into #temp22
    select pid,pro,0,0,0
    from #temp33
    go
      

  3.   

    先建个表#temp22,用游标将#temp33里的数据逐条插入进新表里,其他列添零!
      

  4.   

    成功,感谢wuyi8808,给分!!
    select pid,pro,0,0,0
      

  5.   

    如果需要指定初值,则加上default
    create table #temp22
    (
      pid int not null,
      pro nvarchar(10) not null,
      dianxin int default 0 null,
      wantong int default 0 null,
      qita    int default 0 null
    )
    goinsert into #temp22
    select pid,pro,0,0,0
    from #temp33
    go