Post Pacific  

Go Back   Post Pacific > PC Garage > General PC Talk
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 21.03.2007, 03:18   #1
Digital
Архивный участник
 
Join Date: Nov 2004
Posts: 1,405
Default [Note] What to do when database crash/corrupt?

At Wednesday, October 18, 2006 10:17:00 PM, Bamboo Bends said... Thanks for the blog, saved my ass!

Here's my addition to your site for the case when a database gets crippled by a raid failure.

How to restore an SQL database lost on a raid drive or NT crash with no viable backup.

I've borrowed parts of this from the blog:

http://www.spaceprogram.com/knowledg...ile-on_12.html
(this page is really about recreating a lost ldf file...but has useful info to this task)

This article assumes two things:

You have the data file "recovered_database.mdf" and the log file "recovered_database.ldf"

Copy the files off the damaged drive using your favorite disk restore utility,
you do not need the master databasefiles to do this.

In SQL SERVER ENTERPRISE MANAGER:

1.) Create a new database with the name you choose eg "newdatabase"

2.) Open the SQL Query tool and enter:

EXEC sp_detach_db @dbname = N'newdatabase'

3.) Shut down MS SQL.

4.) Rename the "newdatabase.mdf" and "newdatabase.ldf" files to something else.

5.) Rename your "recovered_database.mdf" and recovered_database.ldf to
"newdatabase.mdf" and "newdatabase.ldf"

6.) Restart SQL server.

7.) Right click on the "database" root node in Enterprise manager and open properties.

8.) Under the Server Settings tab, check on "Allow modifications to be made directly to the system

catalogs".

9.) click ok

10.) Open the SQL Query tool and enter:

EXEC sp_attach_db @dbname = N'newdatabase',
@filename1 = 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\newdatabase.mdf',
@filename2 = 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\newdatabase.ldf'

This will reattach the database files to the SQL server.

11.) Now go to the master database and open the sysdatabases table.

12.) Find the suspected database in here and modify the status column,
setting it to: 32768.

This will put it into emergency mode.

13.) Stop then start sql server

14.) At this stage you've got a database in emergency mode.

15.) Create another databse with Enterprise manager tool.

16.) Using the "Export" option, export the database in emergency state to the just created
database.

17.) The 2nd newly created database will now have a working database (but no stored procedures).

18.) Create a valid backup of the database while you got it in a pristine state.

19.) YOu can detach the emergency state database, your are through with it.

20.) Right click on the "database" root node in Enterprise manager and open properties.

21.) Under the Server Settings tab, UNCHECK on "Allow modifications to be made directly to the

system catalogs".

22.) click ok

23.) You've got SQL!
Digital is offline  
Old 10.08.2007, 17:25   #2
Yui-Ikari
Архивный участник
 
Join Date: Jan 2006
Posts: 58
Default

uhhh ty <3
Yui-Ikari is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 14:45.