schemas.sql 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. if not exists(select s.schema_id from sys.schemas s where s.name = 'optima')
  2. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  3. exec sp_executesql N'create schema [optima] authorization [dbo]'
  4. end
  5. if not exists(select s.schema_id from sys.schemas s where s.name = 'dwh')
  6. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  7. exec sp_executesql N'create schema [dwh] authorization [dbo]'
  8. end
  9. if not exists(select s.schema_id from sys.schemas s where s.name = 'autoline')
  10. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  11. exec sp_executesql N'create schema [autoline] authorization [dbo]'
  12. end
  13. if not exists(select s.schema_id from sys.schemas s where s.name = 'autosys')
  14. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  15. exec sp_executesql N'create schema [autosys] authorization [dbo]'
  16. end
  17. if not exists(select s.schema_id from sys.schemas s where s.name = 'audev')
  18. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  19. exec sp_executesql N'create schema [audev] authorization [dbo]'
  20. end
  21. if not exists(select s.schema_id from sys.schemas s where s.name = 'ari')
  22. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  23. exec sp_executesql N'create schema [ari] authorization [dbo]'
  24. end
  25. if not exists(select s.schema_id from sys.schemas s where s.name = 'datev')
  26. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  27. exec sp_executesql N'create schema [datev] authorization [dbo]'
  28. end
  29. if not exists(select s.schema_id from sys.schemas s where s.name = 'carlo')
  30. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  31. exec sp_executesql N'create schema [carlo] authorization [dbo]'
  32. end
  33. if not exists(select s.schema_id from sys.schemas s where s.name = 'locosoft')
  34. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  35. exec sp_executesql N'create schema [locosoft] authorization [dbo]'
  36. end
  37. if not exists(select s.schema_id from sys.schemas s where s.name = 'werwiso')
  38. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  39. exec sp_executesql N'create schema [werwiso] authorization [dbo]'
  40. end
  41. if not exists(select s.schema_id from sys.schemas s where s.name = 'aa_dwh')
  42. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  43. exec sp_executesql N'create schema [aa_dwh] authorization [dbo]'
  44. end
  45. if not exists(select s.schema_id from sys.schemas s where s.name = '1_dwh')
  46. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  47. exec sp_executesql N'create schema [1_dwh] authorization [dbo]'
  48. end
  49. GO