我用SQL建立的临时表,请问如何知道表是否建立.用何函数才能判断.(必须在程序里判断)

解决方案 »

  1.   

    if exists (select * from dbo.sysobjects where id = object_id('表名')
      

  2.   

    function TForm1.IsTableByName(const TableName: string): Boolean;
    var
      TBList: TStringList;
      Index: Integer;
    begin
      TBList := TStringList.Create;
      try
        AdoConnection1.GetTableNames(TBList, True);
        Result := TBList.Find(TableName, Index);
      finally
        TBList.Free;
      end;
    end;