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

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

