Troubleshooting Guide: Error 1803 — “CREATE DATABASE failed. The primary file must be at least %d MB…”
Why This Error Happens
This error occurs when the primary data file (.mdf) specified in a CREATE DATABASE statement is smaller than the current size of the model database, since SQL Server uses model as a template to construct every new database. It can also surface when a database restore or CREATE DATABASE ... FOR ATTACH operation references a primary file size that no longer matches an enlarged model database (often after a service pack, CU, or manual edit to model‘s file growth settings). Essentially, SQL Server cannot allocate a new database smaller than the system template it is copying from.
Step-by-Step Resolution Guide
Step 1: Check the Current Size of the Model Database
- Open SSMS and connect to the SQL Server 2025 instance.
- Run the following query to check the size of the primary file for
model:
SELECT name, size * 8 / 1024 AS SizeMB
FROM model.sys.database_files;
- Note the
SizeMBvalue — your new database’s primary file must be equal to or larger than this.
Step 2: Adjust the CREATE DATABASE Statement
- Rewrite your
CREATE DATABASEcommand to explicitly set theSIZEparameter equal to or greater than the value found in Step 1. - Example:
CREATE DATABASE MyNewDB
ON PRIMARY
(NAME = MyNewDB_Data,
FILENAME = 'C:\SQLData\MyNewDB.mdf',
SIZE = 20MB,
FILEGROWTH = 10MB);
- Ensure the path (e.g.,
C:\SQLData\) exists and the SQL Server service account has write permissions to it.
Step 3: Reduce the Size of the Model Database (If Oversized Unintentionally)
- If
modelwas accidentally grown too large, connect via SSMS and shrink it:
USE model;
GO
DBCC SHRINKFILE (modeldev, 5);
GO
DBCC SHRINKFILE (modellog, 1);
GO
- Restart the SQL Server service via
services.mscornet stop MSSQLSERVER && net start MSSQLSERVERfor changes to take effect cleanly.
Step 4: Verify Disk Space and File System Permissions
- Confirm the target drive (e.g.,
C:\orD:\SQLData) has sufficient free space beyond the required file size. - Check NTFS permissions on the folder to ensure the SQL Server service account (e.g.,
NT Service\MSSQLSERVER) has Modify rights, as permission issues can mask as sizing errors during file creation.
Alternative or Verification Steps
- Re-run the original
CREATE DATABASEstatement with the correctedSIZEvalue and confirm it completes without Error 1803. - As a quick alternative, omit the
SIZEparameter entirely in yourCREATE DATABASEsyntax — SQL Server will then automatically default to matching themodeldatabase’s file size, bypassing manual miscalculations.