rt

解决方案 »

  1.   

    if exists(select 1 from master..sysdatabases where name='库名')
       print '存在'
    else
       print '不存在'
      

  2.   

    or
    if db_id('库名') is null
       pring '不存在'
      

  3.   

    补充:if has_dbaccess('test1') is null print '没有这个数据库'
      

  4.   

    --检查数据库是不是存在if exists(select name from sysdatabases where name in ('库名'))
        print '此数据库存在'
    else 
        print '此数据库不存在'