Thursday, 22 July 2010

SQL SERVER – FIX : ERROR Msg 1803 The CREATE DATABASE statement failed. The primary file must be at least 3 MB to accommodate a copy of the model database

When creating new data base, its size should be at least the size of the model database, otherwise the CREATE DATABASE statement fails with this error:
The CREATE DATABASE statement failed. The primary file must be at least 3 MB to accommodate a copy of the model database. (Microsoft SQL Server, Error: 1803)

If you like, you can increase the initial size of your new db to at least the size of model database. If not, you can shrink the model database to reduce its size.

To check the available space of a database you can use:
SELECT name ,size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 AS AvailableSpaceInMB
FROM sys.database_files;

About shrinking, have a look at:

DDBC SHRINKDATABASE
DDBC SHRINKFILE