SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Restore database with Attach


Restore database with Attach

Author
Message
Marcin Clays
Marcin Clays
Valued Member
Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)

Group: General Forum Members
Points: 74 Visits: 7
Hi,

I get from client base in .mdf and .ldf
I try to restore this base in my SQL but I have error...
Someone can help me, how can I correct restore this base?
My knowledge SQL is small and I need help.

Error:
Msg 1802, Level 16, State 7, Line 3
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Msg 824, Level 24, State 6, Line 3
SQL Server detected a logical consistency-based I/O error: torn page (expected signature: 0xffffffff; actual signature: 0xf8ae914f). It occurred during a read of page (0:0) in database ID 0 at offset 0000000000000000 in file 'B:\Odzyskane\pse_base_log.ldf'. Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.
John Mitchell-245523
John Mitchell-245523
SSC Guru
SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)

Group: General Forum Members
Points: 133287 Visits: 19360
Did you do what it suggested in the error message? Did your client gracefully shut down SQL Server or detach the database before sending you the files? Do you have the option to ask your client to back up the database and send you the .BAK file?

John
Marcin Clays
Marcin Clays
Valued Member
Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)

Group: General Forum Members
Points: 74 Visits: 7
My client can't give me database in .bak beacouse he was attacked and have encrypted all files... He restore only this files from 02.01.2018

Marcin
Marcin Clays
Marcin Clays
Valued Member
Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)

Group: General Forum Members
Points: 74 Visits: 7
John Mitchell-245523 - Friday, February 9, 2018 2:35 AM
Did you do what it suggested in the error message?

I try use this, but SQL [Could not find stored procedure 'sp_dboption']
use master
declare @databasename varchar(255)
set @databasename='MyDatabase.mdf'
exec sp_dboption @databasename, N'single', N'true'
dbcc checkdb(@databasename,REPAIR_ALLOW_DATA_LOSS)
dbcc checkdb(@databasename,REPAIR_REBUILD)
exec sp_dboption @databasename, N'single', N'false'

John Mitchell-245523
John Mitchell-245523
SSC Guru
SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)

Group: General Forum Members
Points: 133287 Visits: 19360
Where did you get that code?!

Actually, if you can't even restore the database, you've nothing to run a DBCC check against. Is the client saying that they've never backed up the database in the past, or if they have, that all their backup files were destroyed in what I assume was a ransomware attack? If that's the case, the best you can do may be to advise your client to make sure that backups are moved off site as early and as frequently as possible.

John
Marcin Clays
Marcin Clays
Valued Member
Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)

Group: General Forum Members
Points: 74 Visits: 7
Here I get this code: https://www.datanumen.com/sql-recovery/articles/dbcc-checkdb.htm

Yes, client never backed up the database, and yes all files was destroyed by a ransomware attack.

So it is not possible to repair this database?
John Mitchell-245523
John Mitchell-245523
SSC Guru
SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)

Group: General Forum Members
Points: 133287 Visits: 19360
Not sure when that was published, but I suspect it's very out of date. sp_dboption is deprecated: you should use ALTER DATABASE these days.

I'm not looking over your shoulder, so I can't see what you see, but I suspect that the database is indeed not recoverable. How are you attempting to attach the database and at what point do you get the error?

John
Marcin Clays
Marcin Clays
Valued Member
Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)

Group: General Forum Members
Points: 74 Visits: 7
I use this instructions https://docs.microsoft.com/en-us/sql/relational-databases/databases/attach-a-database

When I click extract(query) or when I use function attach database I see this:

===================================

Attach database failed for Server '.\SQL'. (Microsoft.SqlServer.Smo)

------------------------------
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=14.0.17213.0+((SSMS_Rel).171128-2020)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476

------------------------------
Program Location:

at Microsoft.SqlServer.Management.Smo.Server.AttachDatabase(String name, StringCollection files)
at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabaseData.PrimaryFile.Attach()
at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabase.SendDataToServer()

===================================

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

------------------------------
Program Location:

at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType, Boolean retry)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType, Boolean retry)
at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries, Boolean retry)
at Microsoft.SqlServer.Management.Smo.Server.AttachDatabaseWorker(String name, StringCollection files, String owner, AttachOptions attachOptions)
at Microsoft.SqlServer.Management.Smo.Server.AttachDatabase(String name, StringCollection files)

===================================

SQL Server detected a logical consistency-based I/O error: torn page (expected signature: 0xffffffff; actual signature: 0xf8ae914f). It occurred during a read of page (0:0) in database ID 0 at offset 0000000000000000 in file 'B:\Odzyskane\pse_base_log.ldf'. Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (.Net SqlClient Data Provider)

------------------------------
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=824&LinkId=20476

------------------------------
Server Name: .\SQL
Error Number: 824
Severity: 24
State: 6
Line Number: 1


------------------------------
Program Location:

at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType, Boolean retry)
John Mitchell-245523
John Mitchell-245523
SSC Guru
SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)SSC Guru (133K reputation)

Group: General Forum Members
Points: 133287 Visits: 19360
OK, if you can't even attach the database, that limits your options severely. The only thing I can think of is to pay lots of money to a company that specialises in data recovery and see whether they can get it back for you. Maybe someone who knows more about corruption than I do will chip in with some advice.

John
GilaMonster
GilaMonster
SSC Guru
SSC Guru (909K reputation)SSC Guru (909K reputation)SSC Guru (909K reputation)SSC Guru (909K reputation)SSC Guru (909K reputation)SSC Guru (909K reputation)SSC Guru (909K reputation)SSC Guru (909K reputation)

Group: General Forum Members
Points: 909099 Visits: 48840
Yup, I'll chip in with advice:

Ask the client to hunt and see if he has any backups from before he got hit with a ransomware attack, because that file is not attachable. I suspect it too is encrypted and hence unreadable.
Or pay the ransom and hope he gets the key.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search