Se si ottiene l'errore seguente in fase di creazione db:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Could not obtain exclusive lock on database 'model'. Retry the operation later.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (Microsoft SQL Server, Error: 1807)
.. lanciare il seguente script e se escono righe eseguire KILL [ID_Session]
Per ulterior info vedi articolo originale:
https://blog.sqlauthority.com/2016/05/25/sql-server-fix-error-1807-not-obtain-exclusive-lock-database-model-retry-operation-later-part-2/
IF EXISTS ( SELECT request_session_id FROM sys.dm_tran_locks WHERE resource_database_id = DB_ID('model') ) BEGIN PRINT 'Model Database in use!!' SELECT * FROM sys.dm_exec_sessions WHERE session_id IN ( SELECT request_session_id FROM sys.dm_tran_locks WHERE resource_database_id = DB_ID('model') ) END ELSE PRINT 'Model Database not in used.'