Script para eliminar los usuarios de una base de datos
***********************************************/
/* Script killusuarios (SQL Server) */
/* http://www.dbasupport.com.mx */
/* Author: mherlindo */
/**********************************************/
CREATE proc killusuarios
(@dbname varchar(20))
as
declare @dbid int,
@spid int,
@str nvarchar(128)
select @dbid = dbid from master..sysdatabases
where name = @dbname
declare spidcurs cursor for
select spid from master..sysprocesses where dbid = @dbid
open spidcurs
fetch spidcurs into @spid
While @@FETCH_STATUS = 0
Begin
Select @str = 'Kill '+convert(nvarchar(30),@spid)
exec(@str)
print @str
fetch spidcurs into @spid
end
deallocate spidcurs