SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Data Corruption Issues
 database became read only
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

saurav gautam
Starting Member

Nepal
15 Posts

Posted - 11/24/2011 :  05:52:48  Show Profile  Reply with Quote
Hi
Mother board of one of my computer(where sql server database file was stored) got damaged. So i took the hard disk and connected it to another computer.. I attached the database to that next computer's sql server......

But the problem is that the database became 'READ-ONLY'...

I created another 'READ-WRITE' database exactly identical to the read=only database....

Now i want ot move all the data from old database to the new one... How do i do this... I tried to create back-up and restore but i was unsuccessful............please help

saurav123

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 11/24/2011 :  06:04:13  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
Could try ssis to copy the objects?
What went wrong with the backkup and restore? I suspect the database might be corrupt and you are in emergency mode.
Might need to bcp all the data out that you can and bcp into objects in the new database.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

saurav gautam
Starting Member

Nepal
15 Posts

Posted - 11/24/2011 :  06:11:03  Show Profile  Reply with Quote
I want to use loop that gets data one-by-one from currupt database and insert the data/record on another database but i dont know sql code for that.. My algorithm is

STEP 1: for N=1 to 'NUMBER_OF RECORDS"
STEP 2: GET DATA FROM N'TH ROW FROM CURRUPT DATABASE( AND STORE AS VARIABLES)
STEP 3: INSERT THE DATA TO NEW DATABASE TABLE
STEP 4: NEXT N

saurav123
Go to Top of Page

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 11/24/2011 :  07:03:40  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
I would bcp the data out using native format. You can use a view which uses an index to acces the data pages to get round corrpt data pages as long as the index is intact.
create view xxx
as
select *
from tbl
where indexfld <= nnnn
go
First try without the where cluse - that shold use the data pages.
If it fils add the where clause bcp that out - keep trying until you find the max value that works - then use agreater than to get round corrupt data pages.
Then you can bcp into the new database. You might even find you can get all the data from the table by this method - at least you will know what's missing.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

robincham
Starting Member

2 Posts

Posted - 11/25/2011 :  05:36:45  Show Profile  Reply with Quote
hi saurav gautam

Why don't you connect your hard drive to another computer and recover your database in its original format of 'READ-WRITE'. I think this will be easier. You can recover files from corrupted hard drive using third party utility software like Remo Recover software.

You can download the free demo version of this software... I think you must try this..I hope this will work.

Following link can help you
http://www.recoverfiles.org/windows-file-recovery/recover-corrupted-files-from-hard-drive br /
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000