Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restore SQL Server DB without transaction log

Given a SQL Server 2008 .bak file, is there a way to restore the data file only from the .bak file, without the transaction log?

The reason I'm asking is that the transaction log file size of this database is huge - exceeding the disc space I have readily available.

I have no interest in the transaction log, and no interest in any uncompleted transactions. Normally I would simply shrink the log to zero, once I've restored the database. But that doesn't help when I have insufficient disc space to create the log in the first place.

What I need is a way to tell SQL Server to restore only the data from the .bak file, not the transaction log. Is there any way to do that?

Note that I have no control over the generation of the .bak file - it's from an external source. Shrinking the transaction log before generating the .bak file is not an option.

like image 486
LondonPhantom Avatar asked Dec 07 '11 10:12

LondonPhantom


People also ask

Can we restore database without LDF file?

Attach MDF File Without LDF file by using T-SQL script: You can also run a TSQL Script on SQL Query to restore MDF database in SQL Server and recreate your transaction log file. Where, testdb is the name of your database. Now you can check your database in the database folder.

Can you run SQL Server database without log file?

Using T-SQL - Attach a SQL Server Database without a Transaction Log File. DBAs can also attach a SQL Server database without a transaction log file using the below T-SQL code.

How do I restore a SQL Server TRN file?

Right-click the database, point to Tasks, point to Restore, and then click Transaction Log, which opens the Restore Transaction Log dialog box. If Transaction Log is grayed out, you may need to restore a full or differential backup first.


1 Answers

The transaction log is an integral part of the backup. You can't tell SQL Server to ignore the transaction log, because there is no way to let's say restore and shrink the transaction log file at the same time. However, you can take a look at DBA post to hack the process, although it is not recommended at all

Alternatively you could try some third party tools for restoring, particularly virtual restoring process that can save a lot of space and time. Check out ApexSQL Restore, RedGate Virtual Restore, Idera Virtual Database.

Disclaimer: I work for ApexSQL as support engineer

like image 195
Marko Krstic Avatar answered Oct 03 '22 01:10

Marko Krstic