Script to create multiple databases I need to create 90 databases. Something like this. Do you have any idea? 

My script:

declare @db_name nvarchar(100)
set @db_name = 'name';

CREATE DATABASE @db_name
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'@db_name', FILENAME = N'D:\MSSQL11.MSSQLSERVER\MSSQL\DATA\@db_name.mdf' , SIZE = 10240KB , FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'@db_name_log', FILENAME = N'L:\MSSQL11.MSSQLSERVER\MSSQL\Log\@db_name_log.ldf' , SIZE = 512KB , FILEGROWTH = 256KB )
GO
ALTER DATABASE @db_name SET COMPATIBILITY_LEVEL = 110
GO
ALTER DATABASE @db_name SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE @db_name SET ANSI_NULLS OFF 
GO
ALTER DATABASE @db_name SET ANSI_PADDING OFF 
GO
ALTER DATABASE @db_name SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE @db_name SET ARITHABORT OFF 
GO
ALTER DATABASE @db_name SET AUTO_CLOSE OFF 
GO
ALTER DATABASE @db_name SET AUTO_CREATE_STATISTICS ON 
GO
ALTER DATABASE @db_name SET AUTO_SHRINK OFF 
GO
ALTER DATABASE @db_name SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE @db_name SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE @db_name SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE @db_name SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE @db_name SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE @db_name SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE @db_name SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE @db_name SET  DISABLE_BROKER 
GO
ALTER DATABASE @db_name SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE @db_name SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE @db_name SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE @db_name SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE @db_name SET  READ_WRITE 
GO
ALTER DATABASE @db_name SET RECOVERY FULL 
GO
ALTER DATABASE @db_name SET  MULTI_USER 
GO
ALTER DATABASE @db_name SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE @db_name SET TARGET_RECOVERY_TIME = 0 SECONDS 
GO
USE @db_name
GO
IF NOT EXISTS (SELECT name FROM sys.filegroups WHERE is_default=1 AND name = N'PRIMARY') ALTER DATABASE @db_name MODIFY FILEGROUP [PRIMARY] DEFAULT
GO
This piece of SQL can be used as a template:

DECLARE @sql nvarchar(max);
DECLARE @query nvarchar(max);
DECLARE @params nvarchar(500);

SET @params = N'@SQL nvarchar(max), @db_name sysname';
SET @sql= N'SET @SQL=REPLACE(@SQL, ''db_name'', @db_name); print @sql;'
--SET @sql = N'SET @SQL=REPLACE(@SQL, ''db_name'', @db_name); EXEC sp_executesql @SQL;';
SET @query = N'
CREATE DATABASE [db_name]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N''db_name'', FILENAME = N''D:\MSSQL11.MSSQLSERVER\MSSQL\DATA\db_name.mdf'' , SIZE = 10240KB , FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N''db_name_log'', FILENAME = N''L:\MSSQL11.MSSQLSERVER\MSSQL\Log\@db_name_log.ldf'' , SIZE = 512KB , FILEGROWTH = 256KB )
GO
ALTER DATABASE @db_name SET COMPATIBILITY_LEVEL = 110
GO
'



@sql is the piece of SQL that will be executed once for each db
@params is the parameter used by @sql
@query is a string with the piece of SQL use to create a new DB


While playing with @query, be really careful with single and double quotes.

First SET @sql... only prints the query. The second one --SET @sql... will execute it if uncommented.

Then this template can be followed by one more more of the below lines and the whole batch can be executed:

-- template
--
...
EXEC sp_executesql @sql, @params, @query = @query, @db_name = 'xxx';
EXEC sp_executesql @sql, @params, @query = @query, @db_name = 'yyy';
EXEC sp_executesql @sql, @params, @query = @query, @db_name = 'zzz';
...


If db_names are already in a table, this query will output all the EXEC lines:

SELECT N'EXEC sp_executesql @sql, @params, @query = @query, @db_name = '''+col_db_name+''';;' 
FROM db_list;


You can then copy some or all of them after the template and execute the whole batch.

Or without a table, this can simply be used: 

SELECT N'EXEC sp_executesql @sql, @params, @query = @query, @db_name = '''+col_db_name+''';' 
FROM (values
    ('xxx')
    , ('yyy')
    , ('zzz')
    , (...)
    , ...
) as dblist(col_db_name);