Wednesday, March 21, 2012

Recovering a database

Our disk was corrupted and all we maneged to get was the mdf file of a
database (ldf file is lost).
Can I get at least the structure of a database from mdf file or everything
is lost?
regards,Ssimon
Did you do BACKUP of the database, didn't you?
Try to attach a .MDF file by using sp_attach_single_file_db but it might not
work because you did not detach the database firstly
This one I have just found on internet
-- Encountered a situation where the physical log files
-- for a database were deleted and as a result the
-- database was marked suspect.
-- This was the solution to overcoming that issue. The
-- databases in question successfully came back up on
-- line at the end of this.
select dbid, status, name
from sysdatabases
sp_configure 'allow updates', 1
go
reconfigure with override
go
-- puts in emergency repair mode
update sysdatabases
set status = 32768
where dbid = 8
go
-- stop and start sql server
dbcc rebuild_log ('database_name','physical_path_to_log_f
ile')
-- puts in single user mode
update sysdatabases
set status = 4096
where dbid = 8
-- stop and start sql server
use database_name
dbcc checkdb('database_name')
-- reset the status
update master..sysdatabases
set status = 0
where dbid = 8
sp_configure 'allow updates', 0
go
reconfigure with override
go
-- stop and start sql server
select dbid, status
from master..sysdatabases
"simon" <simon.zupan@.stud-moderna.si> wrote in message
news:uYVfCowpFHA.616@.TK2MSFTNGP15.phx.gbl...
> Our disk was corrupted and all we maneged to get was the mdf file of a
> database (ldf file is lost).
> Can I get at least the structure of a database from mdf file or everything
> is lost?
> regards,S
>|||<snip>
> This one I have just found on internet
<snip>
> dbcc rebuild_log ('database_name','physical_path_to_log_f
ile')
<snip>
I suggest you also warn about the downsides using this command. It doesn't c
heck for any type of
consistency. You can have half-finished transactions, missing rollbacks etc.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Uri Dimant" <urid@.iscar.co.il> wrote in message news:%23GiWUswpFHA.3084@.TK2MSFTNGP09.phx.g
bl...
> simon
> Did you do BACKUP of the database, didn't you?
> Try to attach a .MDF file by using sp_attach_single_file_db but it might n
ot work because you did
> not detach the database firstly
>
> This one I have just found on internet
> -- Encountered a situation where the physical log files
> -- for a database were deleted and as a result the
> -- database was marked suspect.
> -- This was the solution to overcoming that issue. The
> -- databases in question successfully came back up on
> -- line at the end of this.
> select dbid, status, name
> from sysdatabases
> sp_configure 'allow updates', 1
> go
> reconfigure with override
> go
> -- puts in emergency repair mode
> update sysdatabases
> set status = 32768
> where dbid = 8
> go
> -- stop and start sql server
> dbcc rebuild_log ('database_name','physical_path_to_log_f
ile')
> -- puts in single user mode
> update sysdatabases
> set status = 4096
> where dbid = 8
> -- stop and start sql server
> use database_name
> dbcc checkdb('database_name')
> -- reset the status
> update master..sysdatabases
> set status = 0
> where dbid = 8
> sp_configure 'allow updates', 0
> go
> reconfigure with override
> go
> -- stop and start sql server
> select dbid, status
> from master..sysdatabases
>
> "simon" <simon.zupan@.stud-moderna.si> wrote in message
> news:uYVfCowpFHA.616@.TK2MSFTNGP15.phx.gbl...
>|||thanks for your answers.
How can I rebuild log if I don't have log file?
I have only mdb file.
regards,S
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:OxEKCmxpFHA.4056@.TK2MSFTNGP10.phx.gbl...
> <snip>
> <snip>
> <snip>
> I suggest you also warn about the downsides using this command. It doesn't
> check for any type of consistency. You can have half-finished
> transactions, missing rollbacks etc.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:%23GiWUswpFHA.3084@.TK2MSFTNGP09.phx.gbl...
>|||there's no magic. If SQL Server has recovery work to perform, and you don't
have the ldf file, you
don't have the information needed to perform that recovery. Either live with
an inconsistent
database, or restore from a good backup. If you do decide to live with a pos
sibly inconsistent
database, I suggest opening a case with MS Support as they might have inform
ation that can be
relevant to you.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"simon" <simon.zupan@.stud-moderna.si> wrote in message news:Ob6plYypFHA.3568@.TK2MSFTNGP10.p
hx.gbl...
> thanks for your answers.
> How can I rebuild log if I don't have log file?
> I have only mdb file.
> regards,S
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote i
n message
> news:OxEKCmxpFHA.4056@.TK2MSFTNGP10.phx.gbl...
>

No comments:

Post a Comment