schemas.sql 978 B

12345678910111213141516171819202122
  1. if not exists(select s.schema_id from sys.schemas s where s.name = 'data')
  2. and exists(select p.principal_id from sys.database_principals p where p.name = 'gaps') begin
  3. exec sp_executesql N'create schema [data] authorization [gaps]'
  4. end
  5. if not exists(select s.schema_id from sys.schemas s where s.name = 'import')
  6. and exists(select p.principal_id from sys.database_principals p where p.name = 'gaps') begin
  7. exec sp_executesql N'create schema [import] authorization [gaps]'
  8. end
  9. if not exists(select s.schema_id from sys.schemas s where s.name = 'imr_csv')
  10. and exists(select p.principal_id from sys.database_principals p where p.name = 'gaps') begin
  11. exec sp_executesql N'create schema [imr_csv] authorization [gaps]'
  12. end
  13. if not exists(select s.schema_id from sys.schemas s where s.name = 'optima')
  14. and exists(select p.principal_id from sys.database_principals p where p.name = 'gaps') begin
  15. exec sp_executesql N'create schema [optima] authorization [gaps]'
  16. end
  17. GO