我要判断SQL-SERVER数据库下的FFFF数据库下的数据表T-BUS 是否存在,我写的代码如下,不知错在哪里,请指教
if exist(select * from sysobjects where name=t-BUS And xtype='u') then 
如何改正,请帮助一下

解决方案 »

  1.   

    if exists (select * from sysobjects where id = object_id('办公室_车辆使用登记簿') and xtype='u')
    --不要  then
      

  2.   

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t-BUS]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)--完整版 还是不要then
      

  3.   

    出现EXISTS未定义的错误,我改成EXIST还是同样的错误,请指教
      

  4.   

    你是什么数据库? 我在 MS SQL 2000下调试通过
      

  5.   

    我用是DELPHI与SQL-SERVER数据库相连接的,我要用DELPHI编写一个小的程序来实现此功能
      

  6.   


    if exist(select * from sysobjects where name=t-BUS And xtype='u') then 
    改为:
    if exist(select * from sysobjects where name='t-BUS' And xtype='u') then
      

  7.   

    在delphi窗口文件中放置TQuery,TDataSourece,TDBGrid,设置好数据库连接属性,参考如下代码:Query1.Close;
    Query1.SQL.Text:='if exists (select * from dbo.sysobjects where id = object_id(N'''[dbo].[t-BUS]''') and OBJECTPROPERTY(id, N'''IsUserTable''') = 1) select * from t-bus';
    try
      Query1.Open;
    except 
    end;应该行了吧。
      

  8.   

    可以利用一个try..except..end来判断,在try..except中加一段打开那个表的过程,不出异常就有了adoconnection有一个gettablenames(stringlist,false)可以将表名列表取到stringlist这个tstrings类的变量