To bring a SQL Server database online or offline you can use a command like the following if your database is named test.

T-SQL
1
2
3
ALTER DATABASE test SET OFFLINE;
 
ALTER DATABASE test SET ONLINE;
ALTER DATABASE test SET OFFLINE;

ALTER DATABASE test SET ONLINE;

When running SQL Server on Amazon’s Relational Database Service it is done a little different. While you can use the command above to take the database offline, you can’t use the command to bring the database online.

I you have a database name test and you execute the following it will work

T-SQL
1
ALTER DATABASE test SET OFFLINE
ALTER DATABASE test SET OFFLINE

You can verify this by running the following

T-SQL
1
2
USE test
GO
USE test
GO

You get the following error

Msg 942, Level 14, State 4, Line 1
Database ‘test’ cannot be opened because it is offline.

If you try running the following command to bring the database online

T-SQL
1
ALTER DATABASE test SET ONLINE;
ALTER DATABASE test SET ONLINE;

Now you get this error

Msg 5011, Level 14, State 9, Line 1
User does not have permission to alter database ‘test’, the database does not exist, or the database is not in a state that allows access checks.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.

So what can you do? RDS has a special stored procedure that will bring the databse online, the name of this stored procedure is rdsadmin.dbo.rds_set_database_online

Here is how you use it

T-SQL
1
2
EXEC rdsadmin.dbo.rds_set_database_online  'test'
GO
EXEC rdsadmin.dbo.rds_set_database_online  'test'
GO

Now you can use the test database again

T-SQL
1
2
USE test
GO
USE test
GO

See, simple, you just have to be aware of these differences