你用这句试试
query1.sql.add('if exists(select 1 from dbo.sysobjects where id=object_id(tempdb..#temp)) drop table #temp')

解决方案 »

  1.   

    query1.sql.add('if exists(select 1 from dbo.sysobjects where object_id('tempdb..#temp') is not null) drop table #temp')
      

  2.   

    谢谢,,我现在就试! 这个tempdb代表什么?
      

  3.   

    踏网无痕的那个运行,出错:tempdb 前缀 无效,无表名
      

  4.   

    列前缀tempdb无效,未指定表名,,请问,这个表名指的是那个名字呢,应该加到什么地方呢?谢谢
      

  5.   

    老忘了单引号,不好意思
    query1.sql.add('if exists(select 1 from dbo.sysobjects where id=object_id('tempdb..#temp')) drop table #temp')
      

  6.   

    query1.sql.add('if exists(select 1 from dbo.sysobjects''') ;
    query1.sql.add('where object_id('''+'tempdb..#temp'+''') is not null) drop table #temp') ;这样才行
      

  7.   

    tempdb就是企业管理器中的tempdb数据库,用来保存临时表的
      

  8.   

    呼救猫,的query1.sql.add('if exists(select 1 from dbo.sysobjects''') ;没看懂,是否少了“)”,,系统给我提示错误:Missing right quote 
      

  9.   

    现在运行的提示是:Error Creating cursor handle