I did a backup and restore today, but I don't know what happened afterwards. The database is in single user mode and can only be used by one user. Other users cannot connect
Many people online say that they execute a stored procedure, kill all user connection processes, and then change to multiple users. After I execute it, it still shows as a single user, and currently a certain user is connecting
So I restarted the MSSQLSERVER service after consulting with the development team, and then executed that stored procedure
The stored procedure is as follows, and change single user to multiple users.
USE [master]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--create a stored procedure to disconnect all users.
create proc [dbo].[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 into @spid
end
close getspid
deallocate getspid
end
GO
use master
exec killspid3 APPDB
ALTER DATABASE APPDB SET MULTI_USER --change from single user to multiple users