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:


So while creating a database, we MUST NOT have any open connection to model database.



Rakesh Mishra

Like us on FaceBook Follow us on Twitter | Join the fastest growing SQL Server group on FaceBook

Follow me on TwitterFollow me on FaceBook