if not exists (select * from master..sysdatabases where name = 'newdb')
begin
  建立newdb数据库。
end

解决方案 »

  1.   

    都已经新建数据库了,还判断吗?在你的客户端登录master库,然后发送:if exists(select * from sysdatabases where name=<你的数据库名>") select 1 else select 0判断返回客户端的值是1还是0。
      

  2.   

    1、
    if exists(select 1 from sysdatabases where name='你的数据库名') 
    select 1 
    else 
    select 02、
    http://www.aspatcn.com/dispbbs.asp?boardid=3&id=201&star=1#440
    http://www.pchomes.com/article/2002/2002-11-13/1438.html
    http://www.swm.com.cn/yingyong/yy-00-11/yy03.htm
    http://www.powerba.com/develop/database/sqlserver/article/20010327002.htm
      

  3.   

    if not exists(select 1 from sysdatabases where name='你的数据库名') 
    begin   ......
    end
      

  4.   

    IF not EXISTS (SELECT name FROM master..sysdatabases WHERE name = N'数据库名')
    begin
    ....--建数据库语句
    end
      

  5.   

    if  db_id('test') is not null
    select 1
    else
    select 2
      

  6.   

    to  黄山GG哈哈。。但如果我有个表也叫test呢???
      

  7.   

    if not exists (select * from master..sysdatabases where name = 'newdb')
    提示语法错误