declare @dbName varchar(32) select @dbName = 'MyData' /* INSERT YOUR DATABASE NAME HERE */ /* Limit the database access to dbo's */ exec sp_dboption @dbName, 'dbo use only', 'true' /* Remove existing users from the database */ exec spKillUsers @dbName /* and here's the sp to kill them all */ /* COPY AND PASTE TO CREATE THE SP */ create procedure spKillUsers @dbName varchar(32) as declare @spid smallint declare @cmd varchar(32) create table #tmp ( spid smallint, status varchar(32), loginame varchar(32), hostname varchar(32), blk char(8), dbname varchar(32), cmd varchar(255)) declare cLogin cursor for select spid from #tmp where dbname = @dbName insert into #tmp exec sp_who open cLogin fetch cLogin into @spid while @@fetch_status = 0 begin select @cmd = 'kill ' + CONVERT(char, @spid) print @cmd execute( @cmd ) fetch cLogin into @spid end close cLogin deallocate cLogin GO grant execute on spKillUsers to public