The CREATE DATABASE statement failed. The primary file must be at least %d MB to accommodate a copy of the model database.

Error Message:
Msg 1803, Level 16, State 1, Line 1
The CREATE DATABASE statement failed. The primary file must be at least %d MB to accommodate a copy of the model database.

Severity level:
16.

Description:
This error message appears when you try to create a database, but the data file is not sufficiently sized to accomodate a copy of the model database.

Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.

Resolution:
Error of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. The data file must be a least the size of the model data file in order for the CREATE DATABASE statement to finish successfully.

Versions:
All versions of SQL Server.

Example(s):
USE master;
IF DB_ID (N’MyExample’) > 0
 DROP DATABASE MyExample;
GO
CREATE DATABASE MyExample
ON PRIMARY
( NAME = MyExample_Data,
    FILENAME = ‘E:MyExample_Data.mdf’,
    SIZE = 1,
    MAXSIZE = 50,
    FILEGROWTH = 15% )
LOG ON
( NAME = MyExample_Log,
    FILENAME = ‘E:MyExample_Log.ldf’,
    SIZE = 5MB,
    MAXSIZE = 25MB,
    FILEGROWTH = 5MB );
GO

Remarks:
In the above example we try to create a database with a size for the data file of 1 MB. Because the model db data file is about 2 MB in size, this error is raised.

Basically SQL Server just copies the model database, wehn you create a new database. Because of this, the data file for the new database, must be at least the size of the model db data file.

]]>

Leave a comment

Your email address will not be published.