I was doing some repairs to a SQL database recently and needed it in single user mode which was the easy part……….USE master; GO ALTER DATABASE dbname SET SINGLE_USER WITH ROLLBACK IMMEDIATE; GOThe issue was then as soon as I went to do my DBCC operation a process had already attached to my database so i found this easy script which drops all open connections to a database:DECLARE @dbname nvarchar(128) SET @dbname = ‘DB name here’ — db to drop connections DECLARE @processid int SELECT @processid = min(spid) FROM master.dbo.sysprocesses WHERE dbid = db_id(@dbname) WHILE @processid IS NOT NULL BEGIN EXEC (‘KILL ‘ + @processid) SELECT @processid = min(spid) FROM master.dbo.sysprocesses WHERE dbid = db_id(@dbname) ENDI was then free to quickly run my additional commands without another process jumping in and grabbing my single user session.