Skip to main content
The referenced "other answer" no longer exists. Incorporated comment.
Source Link
Paul White
  • 90.3k
  • 30
  • 424
  • 663

Your model database is lockedlocked now so what you should do is to find out the session that has a locklock on it, this can be done using sys.dm_tran_locks:

select request_session_id
from sys.dm_tran_locks
where resource_type = 'database' and
      resource_database_id = 3 and
      request_type = 'LOCK' and
      request_status = 'GRANT';

The approach mentioned in another answer can not work if there was no request to model database at all, youYou can have a user that just opened SSMSan SSMS query window with the context of model database and did not ever execute any query there, but that session still holds S lock on databasethe database resource.

Once you have found the locking session, just kill it.

Your model database is locked now so what you should do is to find out the session that has a lock on it, this can be done using sys.dm_tran_locks:

select request_session_id
from sys.dm_tran_locks
where resource_type = 'database' and
      resource_database_id = 3 and
      request_type = 'LOCK' and
      request_status = 'GRANT';

The approach mentioned in another answer can not work if there was no request to model database at all, you can have a user that just opened SSMS query window with the context of model database and did not ever execute any query there, but that session still holds S lock on database resource.

Your model database is locked now so what you should do is to find out the session that has a lock on it, this can be done using sys.dm_tran_locks:

select request_session_id
from sys.dm_tran_locks
where resource_type = 'database' and
      resource_database_id = 3 and
      request_type = 'LOCK' and
      request_status = 'GRANT';

You can have a user that just opened an SSMS query window with the context of model database and did not ever execute any query there, but that session still holds S lock on the database resource.

Once you have found the locking session, just kill it.

Source Link
sepupic
  • 11.2k
  • 17
  • 27

Your model database is locked now so what you should do is to find out the session that has a lock on it, this can be done using sys.dm_tran_locks:

select request_session_id
from sys.dm_tran_locks
where resource_type = 'database' and
      resource_database_id = 3 and
      request_type = 'LOCK' and
      request_status = 'GRANT';

The approach mentioned in another answer can not work if there was no request to model database at all, you can have a user that just opened SSMS query window with the context of model database and did not ever execute any query there, but that session still holds S lock on database resource.