Preventing users from accessing DB while indexes are being rebuilt I need to rebuild the indexes in two very large (almost 750 table) database but want to prevent users from accessing the database while this happens. Is there a state I can put the database in that prevents the users from accessing it but still allows me to rebuild the indexes? For reference I plan on the script provided at http://instadba.com/quick-script-to-defragment-your-sql-server-indexes/ to do the rebuild.
USE master;
GO
ALTER DATABASE YourDatabase 
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO
USE YourDatabase;
--Run index maint scripts...
GO
ALTER DATABASE YourDatabase
SET MULTI_USER;
GO