How do I query if a database schema exists

前端 未结 5 631
野性不改
野性不改 2020-12-25 09:19

As part of our build process we run a database update script as we deploy code to 4 different environments. Further, since the same query will get added to until we drop a r

5条回答
  •  孤独总比滥情好
    2020-12-25 09:49

    If the layout of components allows it, this works too.

    IF EXISTS (SELECT 1 FROM sys.schemas WHERE name = 'myschema') SET NOEXEC ON 
    go
    CREATE SCHEMA myschema
    GO 
    SET NOEXEC OFF -- if any further processing is needed.
    GO
    

提交回复
热议问题