
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 = '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 = 'data') 
	and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
	exec sp_executesql N'create schema [data] authorization [dbo]'
end

if not exists(select s.schema_id from sys.schemas s where s.name = 'transform_ims') 
	and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
	exec sp_executesql N'create schema [transform_ims] authorization [dbo]'
end

if not exists(select s.schema_id from sys.schemas s where s.name = 'transform_imr') 
	and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
	exec sp_executesql N'create schema [transform_imr] authorization [dbo]'
end

if not exists(select s.schema_id from sys.schemas s where s.name = 'test') 
	and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
	exec sp_executesql N'create schema [test] authorization [dbo]'
end

if not exists(select s.schema_id from sys.schemas s where s.name = 'test_systemvergleich') 
	and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin
	exec sp_executesql N'create schema [test_systemvergleich] authorization [dbo]'
end
GO

