Dropping a temporary database

You can drop a temporary database only if it has:

This means that the database:

If any bindings exist, drop database reports a failure. Remove the database from the default group, and unbind all such logins and applications. Use the sp_tempdb “show” interface to determine all bindings involving the temporary database.

If there are any active sessions connected to the database being dropped, drop database fails. Such sessions can exist if they were instantiated before the bindings for the database were removed. To proceed with the drop process, a user must either wait for all such active sessions to drain out of the system, or kill these sessions. Use sp_tempdb “who” dbname to determine what sessions are currently connected to a given temporary database.