Enter Master, then kill all connections with the stored procedure to restore the database to restore the database; **** Kill all processes connected to a database: Create Proc Killspid (@dbname varchar (20)) as begin Declare @SQL NVARCHAR (500) declare @spid int set @ sql = 'declare getspid cursor for select spid from sysprocesses where dbid = db_id (' '' @ dbname '' ')' exec (@sql) open getspid fetch next from getspid into @spid while @@ Fetch_status <> -1 begin exec ('kill' @ spid) fetch next from getspid @spid endspid deallocate getSpid End
- Usage Use master exec killspid 'Database name "Carefully use, may result in data loss