In the previous article, I’ve explained the methods to take a database offline and to attach and detach databases in SQL Server. In this article, I’ll go through the steps and scripts used to bring back the database online. Below are the simple methods for bringing database online from offline state.
Bringing Database Online Using T-SQL
In management studio (SSMS), open a new query window and execute the below Transact-SQL statement. This SQL statement is a simple ALTER DATABASE with the database name and keywords SET ONLINE to bring back the database online.
ALTER DATABASE [Database-Name] SET ONLINE GO
Bringing Database Online Using SSMS
- Login to SQL Server Management Studio.
- In the Object Explorer, right-click the offline database.
- In the right-click menu select Tasks >> Bring Online.
- On selecting Bring Online, a popup window will open and display the status of the action. If the database is brought back online, the popup window displays a tick mark in green button and the status will be success.
- Now, if you refresh database folder in object explorer, you will see the database is online without the red tick mark.
Note: Follow the steps in this article to take the database offline.
Reference
- Details about ALTER DATABASE in Microsoft docs.