password99
Technical User
is there a way to terminate all connections using transact-sql (before performing restore opertaion)
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
declare @spid varchar(10)
declare @dbname varchar(100)
set @dbname = 'DatabaseName'
declare cur CURSOR for select spid from master.dbo.sysprocesses where dbid = (select dbid from master.dbo.sysdatabases where name = @dbname)
open cur
fetch next from cur into @spid
while @@fetch_status = 0
begin
exec ('kill ' + @spid)
fetch next from cur into @spid
end
close cur
deallocate cur
go
restore database ...
go