临时表不用createselect * into #table_name from table where .....

解决方案 »

  1.   

    create  procedure temp2
    as
    Begin
    create table ##zfgzd
    (
      Zfdate datetime,
      Zfdh char (18),
      YearDate char (6),
      Sfbh int,
      Yhbh int,
      Personid int,
      Invoice_number char (20),
      Zfmoney float,
      Re char (30)
    )
    end
    exec temp2
    select * from ##zfgzd
      

  2.   

    你是创建一个实际的表了你是想要用表变量吧?
    declare @zfgzd table 
    (
      Zfdate datetime,
      Zfdh char (18),
      YearDate char (6),
      Sfbh int,
      Yhbh int,
      Personid int,
      Invoice_number char (20),
      Zfmoney float,
      Re char (30)
    )
      

  3.   

    #temp 局部TEMP  TABLE
    ##temp 全局TEMP TABLE-- must drop table ##temp
      

  4.   

    但我现在不想用全局表,这样多用户操作数据带来不便,如果不用存储过程在程序里执行。
    create table ##zfgzd
    (
      Zfdate datetime,
      Zfdh char (18),
      YearDate char (6),
      Sfbh int,
      Yhbh int,
      Personid int,
      Invoice_number char (20),
      Zfmoney float,
      Re char (30)
    )
    select * from #zfgzd
    就可以, 没有其它的办法吗? 如果写在前台程序里,就得连接字符串.不方便.
    就可以
      

  5.   

    临时表不能在存储过程外调用,只能用##temp 全局临时表,那就和建一张普通表一样了