method 1
use master
declare @sql as varchar(20), @spid as int
select @spid = min(spid) from master..sysprocesses where dbid = db_id('OneSource2015_DevTest')
and spid != @@spid
while (@spid is not null)
begin
print 'Killing process ' + cast(@spid as varchar) + ' ...'
set @sql = 'kill ' + cast(@spid as varchar)
exec (@sql)
select
@spid = min(spid)
from
master..sysprocesses
where
dbid = db_id('OneSource2015_DevTest')
and spid != @@spid
end
print 'Process completed...'
if u want to drop db: use below line
Drop database OneSource2015_DevTest
method 2:
method 3
use master
declare @sql as varchar(20), @spid as int
select @spid = min(spid) from master..sysprocesses where dbid = db_id('OneSource2015_DevTest')
and spid != @@spid
while (@spid is not null)
begin
print 'Killing process ' + cast(@spid as varchar) + ' ...'
set @sql = 'kill ' + cast(@spid as varchar)
exec (@sql)
select
@spid = min(spid)
from
master..sysprocesses
where
dbid = db_id('OneSource2015_DevTest')
and spid != @@spid
end
print 'Process completed...'
if u want to drop db: use below line
Drop database OneSource2015_DevTest
method 2:
use master
go
alter database <dbname>
set single_user with rollback immediate
go
alter database <dbname>
set multi_user
go
method 3
alter database database_name
set offline with rollback immediate
go
alter database database_name
set online
go
No comments:
Post a Comment