Solved

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

Posted on 2016-08-11
4
53 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 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:Scott Pletcher
Scott Pletcher 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

737 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