取得一个数据库中的所有数据表的名称和属性
sp_tables

select * from INFORMATION_SCHEMA.TABLES

select * from sysobjects where xtype='U' and status>0

解决方案 »

  1.   

    select * from sysobjects where xtype='U' and status>0 and name=‘你的表名’
    有结果,则存在!
      

  2.   

    if exists(select * from 数据库名..sysobjects where name='要检查的表名')
     print '在'
    else
     print '不在'
      

  3.   

    SELECT name 
      FROM   数据库名..sysobjects 
      WHERE  name = '你的表名' 
      AND   xtype = 'U'
      

  4.   

    -if exists (select * from sysobjects where id = object_id(N'[要检查的表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
      

  5.   

    BEGIN
    IF EXISTS (SELECT * FROM 表名)
    BEGIN
    SELECT * FROM 表名
    END
    END--如果表存在,则提示“命令已成功执行”--如果表不存在,则提示“服务器: 消息 208,级别 16,状态 1,行 2 对象名 '表名' 无效。”