IT:AD:SQL Server:HowTo:Knock users off
Summary
Many DB operations – such as renaming, moving, etc. – require all users bar yourself to be knocked off.
Process
-- Knock everybody off the line:
ALTER DATABASE SomeDb
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
-- do your work...
-- When Finished, allow users back on:
ALTER DATABASE SomeDb
SET MULTI_USER