if exists (select 1 from  dbo.sysobjects 
            where id=object_id('AAA..BBB') AND Xtype='U')
  print '存在'
else print '不存在'

解决方案 »

  1.   

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

  2.   

    if exists (select 1 from  aaa..sysobjects where name='BBB' and xtype='u')
      print '存在'
    else 
      print '不存在'
      

  3.   

    在来一种办法if exists(select * from information_schema.tables where table_name='tablename')
    print '存在'
    else
    print '不存在'
      

  4.   

    use aaa
    go
    if exists(select * from sysobjects where id=object_id('bbb') and name='bbb')
    print 'exist'
    else
    print 'no exist'
      

  5.   

    if object_id('aaa..bbb') IS NOT NULL
    print 'exist'
    else
    print 'no exist'