http://community.csdn.net/Expert/topic/4895/4895674.xml?temp=.7046625
找到了在查询分析器中的写法,在delphi中怎么写啊?
qy1.SQL.Text:='if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[#test]')) drop table[dbo].[#test] ';
qy1.ExecSQL;
这样写老是出错?

解决方案 »

  1.   

    qy1.SQL.Text:='if exists (select * from dbo.sysobjects where id = ''table1'') drop table table1';
    qy1.ExecSQL;
      

  2.   

    qy1.SQL.Text:='if exists(select 1 from tempdb..sysobjects where left(name,len('''+'#1'+'''))='''+'#1'+''') drop table #1';
    qy1.ExecSQL;
      

  3.   

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GisTemp]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [dbo].[GisTemp]
      

  4.   

    if object_id("tempdb..临时表名") drop table 临时表名