I used an existing database to generate a "CREATE"-Script via the MS SQL Server Management Tool. Then i replaced the string literals for the DB Name with variables. However, when i execute the script, it keeps saying "wrong syntax near @DBFullName" (the first use in 'NAME = @DBFullName ...'). I have no idea what the issue is, other than the possibility, that the use of variables is forbidden here.
DECLARE @DBNAME nvarchar(MAX);
SET @DBNAME = 'MyDataBase'
DECLARE @DBFullName text;
SET @DBFullName = 'MySuperDataBase';
DECLARE @DBFileName text;
SET @DBFileName = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.DEVELOPMENT\MSSQL\DATA\\' + @DBName + '.mdf';
DECLARE @DBLogName text;
SET @DBLogName = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.DEVELOPMENT\MSSQL\DATA\\' + @DBName + '.ldf';
CREATE DATABASE [@DBNAME] ON PRIMARY
( NAME = @DBFullName + '_Data', FILENAME = @DBFileName , SIZE = 30720KB , MAXSIZE = UNLIMITED, FILEGROWTH = 10%)
LOG ON
( NAME = @DBFullName + '_Log', FILENAME = @DBLogName , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 10%)
GO