Thursday, January 28, 2016

SQL Server Databsae from SINGLE USER mode to MULTI USER

 
SQL Server 2012 
Right Click on  DB > Properties > Options > [Scroll down] State > RestrictAccess > select Multi_user and click OK.
SQL Server 2008 R2 and earlier
Script to change the database from single user to multi user
--Script
use
master
GO
-- Find the active sessions and kill it
select DB.name, DB.dbid, spid, login_time, nt_domain, nt_username, loginame 
from sysprocesses Process
inner join sysdatabases DB
on Process.dbid = DB.dbid
where DB.name = 'Databsae Name'
GO
kill spid
--Execute the below stored procedure to change to multiuser
exec sp_dboption 'Database Name', 'single user', 'FALSE'

No comments:

Post a Comment