model database is one of the sytem databases that act as a template database for creating new database, also the size of new database should be greater or equal to model database. We can create, modify and drop objects in the Model database. The newly created database will have all the DB objects including data in tables that were there in “model” database at the time of DB creation. In order to guarantee that the content copied from the Model database are consistent , it’s important to have exclusive lock on the model database to prevent copying the data in, delete data from or change in schema of model database.
When we create a database, SQL Server automatically acquires exclusive lock on “model” database. If SQL Server fails to acquire exclusive lock then CREATE DATABASE will fail with following error:
Msg 1807, Level 16, State 3, Line 1
Could not obtain exclusive lock on database 'model'. Retry the operation later.
Msg 1802, Level 16, State 4, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
So while creating a database, we MUST NOT have any open connection to model database.