无法在开始和结束块中使用create schema

时间:2014-05-20 11:05:17

标签: sql sql-server

USE [DRP]

go

IF EXISTS (SELECT *
           FROM   sys.schemas(nolock)
           WHERE  name = N'Config')
  BEGIN
      PRINT 'Config Schema already present'
  END
ELSE
  BEGIN
      EXEC('CREATE SCHEMA [Config]')
      PRINT 'Schema created sucessfully'
  END

它的工作正常,但如果我使用以下代码它不工作,请帮助我

USE [DRP]

go

IF EXISTS (SELECT *
           FROM   sys.schemas(nolock)
           WHERE  name = N'Config')
  BEGIN
      PRINT 'Config Schema already present'
  END
ELSE
  BEGIN
      CREATE SCHEMA [Config]
      PRINT 'Schema created sucessfully'
  END

0 个答案:

没有答案