
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 = 'gaps') begin
	exec sp_executesql N'create schema [data] authorization [gaps]'
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 = 'gaps') begin
	exec sp_executesql N'create schema [import] authorization [gaps]'
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 = 'gaps') begin
	exec sp_executesql N'create schema [imr_csv] authorization [gaps]'
end

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

