Monday, March 19, 2012

Is it possible to access data in a raw .mdf file from another database

Hello
We have a database which has crashed and only have the raw mdf file (and
associated ldf file). Can we import this data into a new database?
Gary
"Gary" <gary@.ggg.com> wrote in message
news:u9kCr8xMHHA.4848@.TK2MSFTNGP04.phx.gbl...
> Hello
> We have a database which has crashed and only have the raw mdf file (and
> associated ldf file). Can we import this data into a new database?
Yes.
Make a copy and then use sp_attach_db to attach it to the server.

> Gary
>
|||Gary
It could be done , but I have seen many times it did not work\
1. From a query window, set the status so that you can update the system
tables by running the following query:
use Master
go
sp_configure "allow", 1
go
reconfigure with override
go
2. Then set the status of the DB that is giving you the problem (XXXXX) into
Emergency Mode by running the following query:
update sysdatabases set status = 32768 where name = '<DBName>'
go
checkpoint
go
shutdown with nowait
go
3. Go into the data directory (MSSQL\DATA) and rename the log file
associated
the DB in question (XXXX.ldf) to some
temporary name, such as XXXX.TMP.
4. Exit the query window.
5. Then start up SQL Server from a DOS command window by issuing:
sqlservr -c -T3608 -T4022.
6. Bring up another query window and verify that the DB is in emergency mode
by issuing:
select Name, Status from Sysdatabases where name = '<DB_Name>'
7. Verify that the status is 32768. If it is, then issue the query:
dbcc traceon(3604)
dbcc rebuild_log('<DB_Name>','<log_filename>') <-- You will need
the quotation marks
REBUILD_LOG should take less than 5 minutes even on a very large
database. It should complete with the message
DBCC execution completed
8. Take the database out of bypass recovery mode by issuing the command
update sysdatabases set status = 0 where name = '<DBName>'
9. Exit the query window and then shutdown (Ctrl-C in the DOS window) and
restart SQL server. Verify the status of the
database by running DBCC NEWALLOC and DBCC CHECKDB on the database.
"Gary" <gary@.ggg.com> wrote in message
news:u9kCr8xMHHA.4848@.TK2MSFTNGP04.phx.gbl...
> Hello
> We have a database which has crashed and only have the raw mdf file (and
> associated ldf file). Can we import this data into a new database?
> Gary
>
|||Greg
If the database was not properly detached (sp_detach) , it may not work .
"Greg D. Moore (Strider)" <mooregr_deleteth1s@.greenms.com> wrote in message
news:OJsKwLyMHHA.4712@.TK2MSFTNGP04.phx.gbl...
> "Gary" <gary@.ggg.com> wrote in message
> news:u9kCr8xMHHA.4848@.TK2MSFTNGP04.phx.gbl...
> Yes.
> Make a copy and then use sp_attach_db to attach it to the server.
>
>

No comments:

Post a Comment