How to find SQL Server database is in use or not?
In order to use a database any session must first obtain a lock on it, usually a shared lock. So simply look for such locks:

select * 
from sys.dm_tran_locks 
where resource_type = 'DATABASE' 
and resource_database_id = &lt;dbid&gt;;