question

moresd34 avatar image
moresd34 asked

Sql server 2012 corrupt ldf file.

I have a corrupt ldf file but a valid mdf file for a db. Is it still possible to restore this database, and sacrifice the transactions that were in progress, or do I need both files? Thanks a lot.
sql-server-2012database-files
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

lokerberg26 avatar image
lokerberg26 answered
You can not to pay money for qualitative answer and get information here: [ http://www.filerepairforum.com/forum/microsoft/microsoft-aa/sql-server/569-i-have-a-problem-how-do-i-fix-a-corrupted-database-file][1] 1.Click the Windows Start button and select "All Programs." In the list of program directories, select "SQL Server" and then click "SQL Server Management Studio." Enter the system administrator user name and password to access the SQL Server. 2. Click the database server name on the left side of the console. This expands a list of databases on your server. Right-click the database that needs to be restored and select "Tasks" and then "Restore." Select "Database." This opens the backup dialog window. 3. Select "From Device" in the list of options in the section labeled "Source for Restore." Click the button labeled "..." to open a dialog box. Click the "Add" button to create a new device for the restore process. 4. Select your LDF file on the hard drive or external media. Click the "Options" button on the left side of the window. In the list of options, select "Restore with Recovery." 5. Click the "OK" button in the dialog box and click "OK" in the main restore template. The database is restored. Restoring a database can take several minutes, depending on the size of your LDF file. Or get info here: **SQL Server Fix Toolbox** Source: [ http://www.fixsqldatabase.com/][2] [1]: http://www.filerepairforum.com/forum/microsoft/microsoft-aa/sql-server/569-i-have-a-problem-how-do-i-fix-a-corrupted-database-file [2]: http://www.fixsqldatabase.com/
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image
ThomasRushton answered
It is possible, but you will lose uncommitted transactions. As you have a valid MDF, but a corrupt LDF, I assume your database is OFFLINE. Assuming the DB has only one LDF, the following steps should sort you out: 1. copy the MDF somewhere safe 2. [Drop the database][1] 3. Copy the MDF back to your normal data directory if the DROP DATABASE command removed the MDF 4. Use a suitable [`sp_attach_single_file_db`][2] command to attach your database. This will create a new LDF for you. 5. Run [`DBCC CHECKDB`][3], just to make sure there's nothing else dodgy in the database. [1]: http://msdn.microsoft.com/en-GB/library/ms178613(v=sql.110).aspx [2]: http://msdn.microsoft.com/en-gb/library/ms174385(v=sql.110).aspx [3]: http://msdn.microsoft.com/en-us/library/ms176064(v=sql.110).aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.