if not exists(select s.schema_id from sys.schemas s where s.name = 'audev_carit') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [audev_carit] authorization [dbo]' end if not exists(select s.schema_id from sys.schemas s where s.name = 'carlo') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [carlo] 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 = 'locosoft') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [locosoft] authorization [dbo]' end if not exists(select s.schema_id from sys.schemas s where s.name = 'navision') and exists(select p.principal_id from sys.database_principals p where p.name = 'dbo') begin exec sp_executesql N'create schema [navision] authorization [dbo]' 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 = 'dbo') begin exec sp_executesql N'create schema [optima] authorization [dbo]' end GO