Tony
Tony

Reputation: 10208

Bring SQL Server database online

I executed the task Take offline of a SQL Server 2008 R2 database.

I cant bring it online!

I tried with

USE master;
GO

ALTER DATABASE [DBNAME] SET ONLINE

I get an error.

User does not have permission to alter database 'DBNAME', the database does not exist, or the database is not in a state that allows access checks.

I also tried using the task Bring online and I get the exact same error.

Can anyone help me asap?

Upvotes: 13

Views: 80367

Answers (3)

Graeme
Graeme

Reputation: 1

Had same problem, same error. Even logged on as SA and returned same error. On both problem database the owner was not SA.

Solved by attaching the database. This gives you the opportunity to rename the database was well assign an owner. Assigned owner as SA.

Detached failed database the renamed the newly attached database to the original name. A lesson in always give SA ownership of new databases.

Upvotes: 0

Russell Fox
Russell Fox

Reputation: 5435

I think you're going to need to login with the SA account, or some other account with sysadmin privileges, and then run your code to put it back online. While you're in there, add sysadmin to your account, too. If you don't own the database, you may need to talk to someone else to get the SA password, or ask them to do it for you. Unless you don't have the SA password or it's been dumbed down for security reasons.

Upvotes: 8

PPC
PPC

Reputation: 1923

Your error is too generic to be usable. Do you actually have the rights to alter the database (I guess you do if you managed to bring it offline)? Can you access teh SQL logs (accessible in the tree via Management > SQL Server logs)? Are you sure the user who is executing the script is the one you expect?

Also, you can try any of the following * restart the service then retry * Use the mouse GUI o bring it online (right click on the DB, Tasks, Bring Online)

Upvotes: 0

Related Questions