Solved

Killing spid's or processes on a sql server from the

Posted on 2016-08-11
4
43 Views
Last Modified: 2016-08-15
I often restore a version of a prod database on top of a test database.  Many times the test database will have active connections that i kill off with the activity monitor in ssms. (allowing the restore to proceed)  Would putting the database in single-user mode offer me the same results of killing all active connections.  what are the risks of putting it in single user mode?

proposed steps.  

put test database in single-user mode
restore production database to the test database.

will the test database be in single user mode after the restore.
0
Comment
Question by:jamesmetcalf74
4 Comments
 
LVL 20

Accepted Solution

by:
Russ Suter earned 250 total points
ID: 41753139
I don't think there's a real advantage to putting the DB into single user mode. If your current process of killing SPIDs is working just stick with that. The restore database dialog does have an option that lets you close connections before proceeding and it warns that it may put the DB into single user mode. However I've never had this happen and if it ever does it's a quick single line query to put it back in to multiuser mode.
DB Restore Options
0
 
LVL 26

Assisted Solution

by:Chris Luttrell
Chris Luttrell earned 125 total points
ID: 41753408
we use this statement all the time and it is what I see from many knowledgeable SQL people:
alter database xxx set single_user with rollback immediate

then do your restore and of course set it back to multi user as your last command
0
 
LVL 69

Assisted Solution

by:ScottPletcher
ScottPletcher earned 125 total points
ID: 41753932
I've had so many issues with trying to get dbs back out of SINGLE_USER mode that I force the db OFFLINE, then restore it.  That also absolutely prevents any new connection from occurring on the db.  By default, the restore puts it back ONLINE (at least in my experience so far, thru SQL 2012 (only)).

ALTER DATABASE [db_name] SET OFFLINE WITH ROLLBACK IMMEDIATE;
RESTORE DATABASE [db_name] ... WITH REPLACE, ...;
0
 

Author Closing Comment

by:jamesmetcalf74
ID: 41756847
thanks gentlemen
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now