If you accidentally brought your SQL 2008 (or later) database offline and cannot connect to the SQL Server anymore, here's how to bring it back online.
- Open SQL Server Management Studio and in the "Connect to Server" dialog box enter your connection parameters
- Click the "Options >>" button and navigate to the "Connections Properties" page
- In the "Connect to database" dialog box type the word master.
- Open a New Query window and paste the following T-SQL code into it:
ALTER DATABASE [Database Name] SET ONLINE
- Replace [Database Name] with your actual database (the one you are trying to bring online)
- Execute the code
- If the code executed successfully, but you do not see the change in your database status, disconnect and reconnect from the server. Then you should be able to connect to your default database instead of master.