CREATE TABLE #MyTempTable (cola INT PRIMARY KEY) 
INSERT INTO #MyTempTable VALUES (1111)
select * from #MyTempTable
drop table #MyTempTable

解决方案 »

  1.   

    是临时表吧,没有临时数据库的if object_id('tempdb..#临时表') is not null
    drop table #临时表
    else 
    creeate table #临时表..
      

  2.   

    if exists(select * from tempdb..sysobjects where name='#MyTempTable' and xtype='u')
      

  3.   

    if not exists(select * from tempdb..sysobjects where name='#MyTempTable' and xtype='u')CREATE TABLE #MyTempTable (cola INT PRIMARY KEY) 
      

  4.   

    if not exists(select * from tempdb..sysobjects where name='#MyTempTable')CREATE TABLE #MyTempTable (cola INT PRIMARY KEY) 
    INSERT INTO #MyTempTable VALUES (1111)
    select * from #MyTempTable
      

  5.   

    谢谢,按caiyunxia(monkey)的代码应该就可以了,谢谢大家了!!!