For disconnecting all the non admin I use the following codes:
ALTER DATABASE folder SET limited_USER WITH ROLLBACK IMMEDIATE
To restore the database. I want to boot developers in which Alter database statement just works on non admins.
Code:
DECLARE @spid varchar(10)
SELECT @spid = spid
FROM master.sys.sysprocesses
WHERE dbid IN (DB_ID('Database1'), DB_ID('Database2'))
WHILE @@ROWCOUNT <> 0
BEGIN
EXEC('KILL ' + @spid)
SELECT @spid = spid
FROM master.sys.sysprocesses
WHERE
dbid IN (DB_ID('Database1'), DB_ID('Database2')) AND
spid > @spid
END
Bookmarks