[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2016-08-11
4
Medium Priority
?
56 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 20

Accepted Solution

by:
Russ Suter earned 1000 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 27

Assisted Solution

by:Chris Luttrell
Chris Luttrell earned 500 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 70

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 500 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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 set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

649 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