schemas.sql 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. if not exists(select s.schema_id from sys.schemas s where s.name = 'export_csv')
  2. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  3. exec sp_executesql N'create schema [export_csv] authorization [dbo]'
  4. end
  5. if not exists(select s.schema_id from sys.schemas s where s.name = 'load')
  6. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  7. exec sp_executesql N'create schema [load] authorization [dbo]'
  8. end
  9. if not exists(select s.schema_id from sys.schemas s where s.name = 'import')
  10. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  11. exec sp_executesql N'create schema [import] authorization [dbo]'
  12. end
  13. if not exists(select s.schema_id from sys.schemas s where s.name = 'imr_csv')
  14. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  15. exec sp_executesql N'create schema [imr_csv] authorization [dbo]'
  16. end
  17. if not exists(select s.schema_id from sys.schemas s where s.name = 'xtract')
  18. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  19. exec sp_executesql N'create schema [xtract] authorization [dbo]'
  20. end
  21. if not exists(select s.schema_id from sys.schemas s where s.name = 'transform')
  22. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  23. exec sp_executesql N'create schema [transform] authorization [dbo]'
  24. end
  25. if not exists(select s.schema_id from sys.schemas s where s.name = 'x_data')
  26. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  27. exec sp_executesql N'create schema [x_data] authorization [dbo]'
  28. end
  29. if not exists(select s.schema_id from sys.schemas s where s.name = 'transform_basis')
  30. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  31. exec sp_executesql N'create schema [transform_basis] authorization [dbo]'
  32. end
  33. if not exists(select s.schema_id from sys.schemas s where s.name = 'load_csv')
  34. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  35. exec sp_executesql N'create schema [load_csv] authorization [dbo]'
  36. end
  37. if not exists(select s.schema_id from sys.schemas s where s.name = 'transform_config')
  38. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  39. exec sp_executesql N'create schema [transform_config] authorization [dbo]'
  40. end
  41. if not exists(select s.schema_id from sys.schemas s where s.name = 'temp')
  42. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  43. exec sp_executesql N'create schema [temp] authorization [dbo]'
  44. end
  45. if not exists(select s.schema_id from sys.schemas s where s.name = 'load_union')
  46. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  47. exec sp_executesql N'create schema [load_union] authorization [dbo]'
  48. end
  49. if not exists(select s.schema_id from sys.schemas s where s.name = 'load_2')
  50. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  51. exec sp_executesql N'create schema [load_2] authorization [dbo]'
  52. end
  53. if not exists(select s.schema_id from sys.schemas s where s.name = 'batch')
  54. and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
  55. exec sp_executesql N'create schema [batch] authorization [dbo]'
  56. end
  57. GO