Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 Administration
»
Urgent help in Script to restore the database...
Urgent help in Script to restore the database by creating empty log file
Rate Topic
Display Mode
Topic Options
Author
Message
Mac1986
Mac1986
Posted Thursday, February 14, 2013 12:13 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Yesterday @ 6:28 PM
Points: 180,
Visits: 513
Hi,
I have a situation where in I need to restore a .BAK file and i do not have enough disk space to restore the entire Data and log files from the .BAK file.
Is there a way than I can just restore the data and not restore the log file. OR create a an empty log file while restoring and not considering the huge log file from the .BAK file?
I'm using SQL Server 2008 R2 version.
Post #1419834
- Win
- Win
Posted Thursday, February 14, 2013 12:23 AM
SSC Journeyman
Group: General Forum Members
Last Login: Thursday, May 09, 2013 12:06 AM
Points: 86,
Visits: 318
I dont think you can just restore a MDF file avoiding LDF from a full backup file.
Attach, detach will do. You should be able to attach the database with just the MDF file.
It will create one LDF file automatically for you with default size.
Found somthing for you, hope it helps.
--Step 1: Retrive the Logical file name of the database from backup.
RESTORE FILELISTONLY
FROM DISK = ‘G:\TransDB_Full.BKP’
GO
--Step 2: Use the values in the LogicalName Column in following Step.
—-Make Database to single user Mode
ALTER DATABASE TransDB
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE
—-Restore Database
RESTORE DATABASE TransDB
FROM DISK = ‘G:\TransDB_Full.BKP’
WITH
MOVE ‘O1_SITEDB’ TO ‘J:\TransDB_Data.mdf’,
MOVE ‘O1_SITEDB_Log’ TO ‘C:\TransDB_Log.ldf’
/*If there is no error in statement before database will be in multiuser mode.
If error occurs please execute following command it will convert database in multi user.*/
ALTER DATABASE TransDB SET MULTI_USER
GO
Cheers,
- Win
"Dont Judge a Book by its Cover"
Post #1419840
GilaMonster
GilaMonster
Posted Thursday, February 14, 2013 1:43 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 2:33 PM
Points: 37,741,
Visits: 30,019
Mac1986 (2/14/2013)
Is there a way than I can just restore the data and not restore the log file. OR create a an empty log file while restoring and not considering the huge log file from the .BAK file?
No. You'll need to find the disk space to restore the DB. A restore puts the database down as it was at the time of backup, file sizes included.
p.s. Log files aren't optional files that you can just not restore or delete without consequence.
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
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
Post #1419867
anthony.green
anthony.green
Posted Thursday, February 14, 2013 1:47 AM
SSCertifiable
Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075,
Visits: 4,831
Mac1986 (2/14/2013)
Hi,
I have a situation where in I need to restore a .BAK file and i do not have enough disk space to restore the entire Data and log files from the .BAK file.
Is there a way than I can just restore the data and not restore the log file. OR create a an empty log file while restoring and not considering the huge log file from the .BAK file?
I'm using SQL Server 2008 R2 version.
As Win said you cant do it. SQL needs to restore the database to as it was when it was backed up. So if you have a 10GB MDF and a 1000GB LDF and thats how it was when it was backed up to the BAK file, SQL has to restore it as such.
As Win said, you could do a detach / attach single file DB, but this can be risky and not always successful, as the log is not a throw away file, so you could detach while things are going on, and when it attaches without the log chain in the log fails and causes you more problems.
The only safe way would be to ensure you have enough disk space on the destination server to ensure you can restore as it was backed up.
Failing that, you could look at shrinking the transaction log, but that again could be dodgy, backing up and then restoring to destination.
Also why is the log so big? Has the DB got proper transaction log maintenance running on it?
Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1
&
Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger
Post #1419871
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.