Primary File size error while creating database
All newly created databases use the Model database as a template. The new databases will start out no smaller than the Model database.
the error you are receiving indicates that the model database size is 32MB.
to fix it, create the database with a size larger than the model database size.
you can also shrink the model database to reduce its size.
Sample code to create database with custom size
CREATE DATABASE Tests
ON
( NAME = 'Tests',
FILENAME = 'c:\tests.mdf',
SIZE = 33000KB )
GO
When SQL Server creates a new database, it copies the model
database as a template. model
(depending on your version) has a specific initial size.
See this MSDN blog for details.
You are declaring your new database should have an initial size of 3MB:
CREATE DATABASE [MyDatabase] ON PRIMARY
( NAME = N'MyDatabase_Data', FILENAME = N'D:\SQL SERVER\DataFiles\MyDatabase\MyDatabase.MDF' , SIZE = 3096KB , MAXSIZE = 29687808KB , FILEGROWTH = 262144KB )
You need to increase the starting size to accommodate your model
database' initial size.
NB: The default model is 3MB (on SQL Server 2012 - less on lower versions) -- you may want to look into why yours is 4MB.