Awesome, Great question. 🙂
Considering there is one transaction which is still not committed ,If executed the below command then
-- #1
ALTER DATABASE LOCALWORK SET OFFLINE WITH NO_WAIT
-- RESULT
Msg 5070, Level 16, State 2, Line 1
Database state cannot be changed while other users are using the database 'LocalWork'
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
-- #2
ALTER DATABASE LOCALWORK SET OFFLINE WITH ROLLBACK IMMEDIATE
-- RESULT
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
-- #3
ALTER DATABASE LOCALWORK SET OFFLINE
-- OR
Going to the menu and tasks and then selecting "Take Offline" (right-click on the specific database)
-- RESULT
Msg 5061, Level 16, State 1, Line 1
ALTER DATABASE failed because a lock could not be placed on database 'LOCALWORK'. Try again later.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.