if not exists(select s.schema_id from sys.schemas s where s.name = 'export_csv') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [export_csv] authorization [dbo]' end if not exists(select s.schema_id from sys.schemas s where s.name = 'load') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [load] authorization [dbo]' end if not exists(select s.schema_id from sys.schemas s where s.name = 'import') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [import] authorization [dbo]' end if not exists(select s.schema_id from sys.schemas s where s.name = 'imr_csv') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [imr_csv] authorization [dbo]' end if not exists(select s.schema_id from sys.schemas s where s.name = 'xtract') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [xtract] authorization [dbo]' end if not exists(select s.schema_id from sys.schemas s where s.name = 'transform') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [transform] authorization [dbo]' end if not exists(select s.schema_id from sys.schemas s where s.name = 'x_data') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [x_data] authorization [dbo]' end if not exists(select s.schema_id from sys.schemas s where s.name = 'transform_basis') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [transform_basis] authorization [dbo]' end if not exists(select s.schema_id from sys.schemas s where s.name = 'load_csv') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [load_csv] authorization [dbo]' end if not exists(select s.schema_id from sys.schemas s where s.name = 'transform_config') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [transform_config] authorization [dbo]' end if not exists(select s.schema_id from sys.schemas s where s.name = 'temp') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [temp] authorization [dbo]' end GO