SQLMaster
SQLMaster

Reputation:

How to set a database in emergency mode?

my database is stoped. i can't make anything, select, update, nothing. somebody told me to set the database in emergency mode but i don't know how?

Upvotes: 4

Views: 26154

Answers (4)

vijay malani
vijay malani

Reputation: 11

USE [master] GO
-- Method 1: I use this method
EXEC sp_attach_single_file_db @dbname='TestDb',
@physname=N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf'
GO
-- Method 2:
CREATE DATABASE TestDb ON
(FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf')
FOR ATTACH_REBUILD_LOG
GO

Upvotes: 0

user2722833
user2722833

Reputation: 11

If your databse is in suspect mode, you will have to keep that database in emergencey mode (to gain acesses to that DB).

alter database datasename set emergency

Then run DBCC statement as:

dbcc chedkdb(DBname,repair_rebuild) with no_infomsgs

If this doesnt work ,then keep the DB in singleuser mode like below and run checkdb statement

alter database DBname set single_user
dbcc checkdb(DBname,repair_allow_data_loss) with no_infomsgs

If that succeeds,now keep the DB online by

alter database DBname set multi_user

Upvotes: 0

SQLMaster
SQLMaster

Reputation:

i found the solution : ALTER DATABASE dbName SET Emergency

Upvotes: 2

Iralda Mitro
Iralda Mitro

Reputation: 7366

i think this is only for Server DB, or not?

in SQL Documentation was a query like this:

set emergency mode "databasename"

try it on! cos' I have only Express Edition of SQL Server here

Upvotes: 0

Related Questions