when trying to run the following query in order to create a new database:
CREATE DATABASE [Lunch]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'Lunch',
FILENAME = N'E:\Data Files\Lunch.mdf' ,
SIZE = 110592KB , FILEGROWTH = 1048576KB ),
FILEGROUP [DATA]
( NAME = N'Lunch_Data',
FILENAME = N'E:\Data Files\Lunch_Data.ndf' ,
SIZE = 110592KB , FILEGROWTH = 1048576KB ),
FILEGROUP [NONCLUSTERED_INDEXES]
( NAME = N'Lunch_nonclusteredindexes',
FILENAME = N'E:\Data Files\Lunch_nonclusteredindexes.ndf' ,
SIZE = 110592KB , FILEGROWTH = 1048576KB )
LOG ON
( NAME = N'Lunch_log',
FILENAME = N'F:\logFiles\Lunch_log.ldf' ,
SIZE = 524288KB ,
FILEGROWTH = 524288KB )
GO
Getting the following error message:
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.
what is using the model database and does not allow me to obtain the exclusive lock?
modelis locked due to a backup or some other system process, stop the session could do a lot of harm to your system. Check to see what user owns that session and what that user is doing before deciding whether to kill it or wait out the lock. – nateirvin Mar 18 '22 at 04:45