Monday, March 26, 2012

recovery db from files *.mdf and *.ldf

Hi
My server machine had problems, and i had that reinstall, and I only can recover the files *.mdf, and *.ldf.
I tried to recover the one db with the command:
EXEC sp_attach_db @.dbname =3D'viaticos', @.filename1 =3D 'F:\Microsoft SQL Server\MSSQL\Data\Viaticos_Data.mdf', @.filename2 =3D 'F:\Microsoft SQL Server\MSSQL\Data\Viaticos_log.ldf'
and
EXEC sp_attach_single_file_db 'viaticos', @.physname =3D 'F:\Microsoft SQL
Server\MSSQL\Data\Viaticos_Data.MDF'
But, the last commnad can create the db, and generated the follow error;
Error de activaci=F3n de dispositivo. El nombre de archivo f=EDsico 'f:\Microsoft
SQL Server\MSSQL\data\Viaticos_Log.LDF' puede ser incorrecto.
Se cre=F3 un nuevo archivo de registro llamado 'F:\Microsoft SQL
Server\MSSQL\Data\viaticos_log.LDF'.
With this option I can see the store procedure and views, but i don't see the data and definitions of tables, and
generated this error:
SQL-DMO(ODBC SQLState:08S01
Error 0: this server has been disconected. You must reconnected to perform this operation
Error 823.
and
Error 22528[SQL-DMO] This server connect has been unexpected broken and cannot be reconected.
How I do for recover the data and structure of tables?
than's.Do you not have proper backups?
You could *try* sp_attach_single_file_db against just the MDF file, but if
SQL Server crashed and it wasn't detached correctly, I'm not very
optimistic.
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"Ivan Alexander Laverde G" <anonymous@.discussions.microsoft.com> wrote in
message news:fe6101c43ea3$ee330950$a501280a@.phx.gbl...
Hi
My server machine had problems, and i had that reinstall,
and I only can recover the files *.mdf, and *.ldf.
I tried to recover the one db with the command:
EXEC sp_attach_db @.dbname ='viaticos',
@.filename1 = 'F:\Microsoft SQL
Server\MSSQL\Data\Viaticos_Data.mdf',
@.filename2 = 'F:\Microsoft SQL
Server\MSSQL\Data\Viaticos_log.ldf'
and
EXEC sp_attach_single_file_db 'viaticos', @.physname
= 'F:\Microsoft SQL
Server\MSSQL\Data\Viaticos_Data.MDF'
But, the last commnad can create the db, and generated the
follow error;
Error de activación de dispositivo. El nombre de archivo
físico 'f:\Microsoft
SQL Server\MSSQL\data\Viaticos_Log.LDF' puede ser
incorrecto.
Se creó un nuevo archivo de registro llamado 'F:\Microsoft
SQL
Server\MSSQL\Data\viaticos_log.LDF'.
With this option I can see the store procedure and views,
but i don't see the data and definitions of tables, and
generated this error:
SQL-DMO(ODBC SQLState:08S01
Error 0: this server has been disconected. You must
reconnected to perform this operation
Error 823.
and
Error 22528[SQL-DMO] This server connect has been
unexpected broken and cannot be reconected.
How I do for recover the data and structure of tables?
than's.|||Hi ,
Try the below steps, it might work if you are lucky.
1. Create a new database with the same name
2. Mention the file names (MDF and LDF ) same as old but in different
3. After you create the new database, stop SQL Server
4. Copy the old database files (MDF and LDF) over the top of the new ones.
5 SQL Server will recognize the database.
6. Database will started in suspect status
7. Update the database status to emergency mode (use below script in Query
Analyzer)
Sp_configure "allow updates", 1
go
Reconfigure with override
GO
Update sysdatabases set status = 32768 where name = "BadDbName"
go
Sp_configure "allow updates", 0
go
Reconfigure with override
GO
8. Now the database will be open for read only (with out using Transaction
log)
9. Create a new database and use DTS to move the data and objects from old
database to new database
Note:
After step-7 try DBCC Checkdb with repair options (See books online) and see
if it can be repaired.
Thanks
Hari
MCDBA
"Ivan Alexander Laverde G" <anonymous@.discussions.microsoft.com> wrote in
message news:fe6101c43ea3$ee330950$a501280a@.phx.gbl...
Hi
My server machine had problems, and i had that reinstall,
and I only can recover the files *.mdf, and *.ldf.
I tried to recover the one db with the command:
EXEC sp_attach_db @.dbname ='viaticos',
@.filename1 = 'F:\Microsoft SQL
Server\MSSQL\Data\Viaticos_Data.mdf',
@.filename2 = 'F:\Microsoft SQL
Server\MSSQL\Data\Viaticos_log.ldf'
and
EXEC sp_attach_single_file_db 'viaticos', @.physname
= 'F:\Microsoft SQL
Server\MSSQL\Data\Viaticos_Data.MDF'
But, the last commnad can create the db, and generated the
follow error;
Error de activación de dispositivo. El nombre de archivo
físico 'f:\Microsoft
SQL Server\MSSQL\data\Viaticos_Log.LDF' puede ser
incorrecto.
Se creó un nuevo archivo de registro llamado 'F:\Microsoft
SQL
Server\MSSQL\Data\viaticos_log.LDF'.
With this option I can see the store procedure and views,
but i don't see the data and definitions of tables, and
generated this error:
SQL-DMO(ODBC SQLState:08S01
Error 0: this server has been disconected. You must
reconnected to perform this operation
Error 823.
and
Error 22528[SQL-DMO] This server connect has been
unexpected broken and cannot be reconected.
How I do for recover the data and structure of tables?
than's.sql

No comments:

Post a Comment