How to Kill SPID's and get a database out of single user mode.

Sometimes when working with a database, especially a SharePoint database you will have to put it in single server mode to restore. This method of recovery is not supported by Microsoft, so only use in non-production environments (i.e. moving prod data to a lower environment for testing.)

Often when doing this the database-chatty SharePoint application, will grab your single user mode database prior to you getting a chance to run a restore or whatever you are doing. If you do get locked out you will see the following error message.  This is how to get it back!
Error Message:


Database 'WSS_Content_YourDB' is already open and can only have one user at a time. (Microsoft SQL Server, Error: 924)




select spid from master..sysprocesses
where dbid = db_id('WSS_Search_YourDB') and spid <> @@spid



--Once you find out the spid numbers you can simply run the kill command
kill (spid number that you got from the previous query) example:
--kill yourSPID i.e.
kill 56

Comments

Popular posts from this blog

Metastorm - Open form in an action from a list or link

Corporate Intranet Information Architecture – a Publishing Site

No Search Results in SharePoint Contextual Search OSSSearchResults.aspx