Mundy

IT Knowledge Base

User Tools

Site Tools


take_a_database_offline_in_microsoft_sql_server

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

take_a_database_offline_in_microsoft_sql_server [2018/04/09 09:56] (current)
Line 1: Line 1:
 +====== Take a Database Offline in Microsoft SQL Server ======
  
 +In SQL Server Management Studio, right click the database, Tasks > Take Offline
 +
 +If it seems to take too long, see [[http://​blog.degree.no/​2013/​03/​long-wait-time-when-taking-sql-server-database-offline/​|Long wait-time when taking SQL Server database offline | Degree Blog]]:
 +
 +<​code>​ALTER DATABASE <​dbname>​ SET OFFLINE WITH ROLLBACK IMMEDIATE</​code>​
 +
 +In some cases you might get an error saying:
 +
 +<​code>​ALTER DATABASE failed because a lock could not be placed on database '​dbname'​ Try again later.</​code>​
 +
 +After you get this error, run
 +
 +<​code>​EXEC sp_who2</​code>​
 +
 +Look for the database in the result and find the SPID for that connection, then run
 +
 +<​code>​KILL <​SPID></​code>​
take_a_database_offline_in_microsoft_sql_server.txt ยท Last modified: 2018/04/09 09:56 (external edit)