Subscribe to
Posts
Comments

Did you experienced a situation where a database was used by a high traffic 24/7 web application and somehow some important data got deleted and need a restoration? The database was located on a server that had a few other important databases and it was located in a data center far away and you couldn’t disconnect the database server from the network.

In this situation if you try to restore the database you may find it always fail with an error message saying somebody else is using the database. What can you do to restore the database? You may want to stop the web servers first and wait till all the connections are gone then restore the database. It may work but in a load balanced web site that means you may have to stop a list of web servers. The worse case is that there may be applications other than the web site accessing the database. Probably killing all the processes that are accessing the database using Enterprise Manager or Query Analyzer and then restore it? Most likely it will fail either because hundred thousands of users are using the web site the second you kill a connection a new one is created by the web servers.

A convenient way to handle this situation is to temporary take out the database user that the applications use to access the database. The following screen shot shows how to remove a database user.

remove sql server database user

Once you take out these database users you can kill the existing processes that are accessing the database knowing that no new connection to the database is allowed. After that the database can be restored without complaining. When database restoration is done you can run the following query to re-associate the database users to database logins.

sp_change_users_login @Action = 'Auto_Fix'


Related Posts:

  • Filegroup
  • A CommVault Galaxy QiNetix Bug Experienced in Restoring SQL Server Database
  • The Best Way to Backup SQL Server
  • How to Separate Data and Indexes of a Table into Different Files
  • MySQL vs SQL Server in Data File Management


  • 1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...

    RSS feed | Trackback URI

    Comments »

    No comments yet.

    Name (required)
    E-mail (required - never shown publicly)
    URI
    Subscribe to comments via email
    Your Comment (smaller size | larger size)
    You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.