क्वेरी ब्लॉक के नीचे मददगार हो सकता है।
DECLARE @Query VARCHAR(MAX)=''
DECLARE @DbName VARCHAR(400) = 'Db1'
DECLARE @DbFilePath VARCHAR(400) = 'E:\Database\'
SET @Query = @Query + 'CREATE DATABASE '[email protected] +' ON PRIMARY '
SET @Query = @Query + '( NAME = '''[email protected] +''', FILENAME = '''[email protected][email protected] +'.mdf'' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) '
SET @Query = @Query + ' LOG ON '
SET @Query = @Query + '( NAME = '''[email protected] +'_log'', FILENAME = '''[email protected][email protected] +'_log.ldf'' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)'
print @query
exec(@query)