Extended64
The 64-Bit Windows Community

Shrink SQL Server 2008 Database Log File Script

Here is a quick script to shrink the database log file in a SQL Server 2008 database.  This procedure has changed, since the BACKUP command does not work the same way as previous versions.  Replace DatabaseName with the name of your database, and LogFileName with logical name of your log file.

   1: Use DatabaseName 
   2: GO
   3: Alter Database DatabaseName Set Recovery Simple
   4: GO
   5: Alter Database DatabaseName Set Recovery Full
   6: GO
   7: DBCC SHRINKFILE ('LogFileName', 1)
   8: GO
   9: DBCC SHRINKFILE ('LogFileName', 1)
  10: GO
  11: DBCC SHRINKFILE ('LogFileName', 1)
  12: GO
  13: DBCC SHRINKFILE ('LogFileName', 1)
  14: GO
  15: DBCC SHRINKFILE ('LogFileName', 1)
  16: GO
  17: DBCC SHRINKFILE ('LogFileName', 1)
  18: GO

Posted Jun 11 2009, 03:44 AM by Ryan Hoffman

Comments

Twitted by tekmaven wrote Twitted by tekmaven
on 07-24-2009 3:21 AM

Pingback from  Twitted by tekmaven

SqlServerKudos wrote Shrink SQL Server 2008 Database Log File Script
on 07-26-2009 8:29 PM

Kudos for a great Sql Server article - Trackback from SqlServerKudos

Aaron Bertrand wrote Oh, the horror! Please stop telling people they should shrink their log files!
on 07-27-2009 11:52 AM

I realize that there are some cases where, in an emergency, you need to shrink a log file because it

Nick224422 wrote re: Shrink SQL Server 2008 Database Log File Script
on 01-12-2010 3:12 PM

Is this script in right order? shouldn't it be shrinked while its in simple recovery ....then back to Full ? I want to use it but just want to make sure first.

Default wrote Awesome script for shrinking a SQL 2008 database log
on 05-25-2010 11:44 PM
sql 2008 shrink log file wrote sql 2008 shrink log file
on 05-26-2010 2:43 PM

Pingback from  sql 2008 shrink log file

LionelDraper wrote re: Shrink SQL Server 2008 Database Log File Script
on 02-08-2011 9:39 PM

I really miss the backup command in the old SQL.  I don't know why they got rid of that.  Right now I mostly use a mac.  I could however use <a href="http://www.bluelock.com" rel"follow">VMWare</a> to boot up a windows machine to do this.  Do you all know it this works?

jurgenliastr wrote re: Shrink SQL Server 2008 Database Log File Script
on 04-13-2011 3:23 AM

I'm the same way, I do my best to remain neutral. It's hard, if you communicate with the person the other person dislikes,<a href="www.papermoz.com/.../">Research Papers</a> <a href="www.papermoz.com/.../a> <a href="www.papermoz.com/.../a> then you fall out of favor with them! I simple can't dislike a person, just because someone else does, I just can't.

joshgeake wrote re: Shrink SQL Server 2008 Database Log File Script
on 04-15-2011 4:07 PM

I wrote a post about this a while ago - it's a pretty simple statement. See here...

www.geakeit.co.uk/.../sql-log-file-is-huge

annie12 wrote re: Shrink SQL Server 2008 Database Log File Script
on 07-05-2011 9:25 AM

We might consider taking benefit from of internal IDE feature, such as by dragging over the text in Visual Studio and toolkit that is also good XAML code snippets. I am going to describe what I mean explanation.

<a href="http://www.jihoy.com">free ads</a>|<a href="www.tradesparq.com/">importing from china</a>

annie12 wrote re: Shrink SQL Server 2008 Database Log File Script
on 07-05-2011 9:26 AM

How come it is working for me either in windows 7 or 8? Maybe you should try re-installing it buddy.

rebena wrote re: Shrink SQL Server 2008 Database Log File Script
on 07-28-2011 3:19 AM

I just found your site and wanted to say that I have really enjoyed browsing your posts.In any case I'll be subscribing to your blog and I hope you post again soonwww.android-developers.in

laserlight wrote re: Shrink SQL Server 2008 Database Log File Script
on 08-10-2011 4:17 AM

I always surf everyday to check if there are beautiful sites and I found that this could be cool.There are lots of conversation and important information here. It helps me a lot to look forward my daily needs in your blog thanks for sharing

<a href="www.siteserving.com/.../">VPS Hosting</a>

laserlight wrote re: Shrink SQL Server 2008 Database Log File Script
on 08-10-2011 4:24 AM

I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept.

<a href="www.siteserving.com/.../">Web Hosting</a>

samstonz wrote re: Shrink SQL Server 2008 Database Log File Script
on 08-11-2011 1:55 AM

This is a wonderful summary of the blogs I check every goggle and observed this same subject. I could not find a significant other ideas and information specifically for this mission<a href="http://www.pass4sureonline.net">pass4sure</a>/<a">http://www.pass4sureonline.net">pass4sure</a>/<a href="http://www.pass4sureonline.net">pass 4 sure</a>/<a href="http://www.pass4sureonline.net">passforsure</a>/<a href="www.pass4sureonline.net/CCNA.html">ccna certification</a>/<a href="www.pass4sureonline.net/.../<a href="www.pass4sureonline.net/CCIP.html">ccip exam</a>/<a href="www.pass4sureonline.net/CCNP.html">ccnp certification</a>/<a href="www.pass4sureonline.net/CCNP-Voice.html">ccnp voice</a>/<a href="www.pass4sureonline.net/.../<a href="www.pass4sureonline.net/CCVP.html">ccvp certifications</a>

Ana Boks wrote re: Shrink SQL Server 2008 Database Log File Script
on 08-22-2011 5:21 AM

Hey must say such an interesting article it is. I just read it and i really appreciate your ideas. Thanks for sharing such a nice blog with us.

Ana Boks wrote re: Shrink SQL Server 2008 Database Log File Script
on 08-24-2011 7:13 AM

Thanks a lot for the informative and interesting publication first of all. Actually I was looking for this information for a long time and finally have noticed this your entry.

<a href="http://www.mobilecubix.com">iPhone Application Development </a>

abhishek644 wrote re: Shrink SQL Server 2008 Database Log File Script
on 08-25-2011 4:32 AM

I am thoroughly impressed by the way you present your article.Thanks a lot admin you have done good work over here

mission statement samples wrote re: Shrink SQL Server 2008 Database Log File Script
on 09-03-2011 6:43 AM

I admire what you have done here. I like the part where you say you are doing this to give back but I would assume by all the comments that this is working for you as well

[url=www.solidlineproducts.com]ipad keyboard[/url]

cadee wrote re: Shrink SQL Server 2008 Database Log File Script
on 09-04-2011 2:03 PM

Finding worthy blogs is not easy now and it's a pleasure to run across your site. As they say one cannot be too careful.

It must be admitted that your explanation is very easy to take in. I am sure that most of your observations are true.

<a href="http://www.earthwisebags.com">custom reusable bags </a>

cadee wrote re: Shrink SQL Server 2008 Database Log File Script
on 09-04-2011 2:05 PM

Finding worthy blogs is not easy now and it's a pleasure to run across your site. As they say one cannot be too careful.

It must be admitted that your explanation is very easy to take in. I am sure that most of your observations are true.

<a href="http://www.earthwisebags.com">custom reusable bags </a>

jonisonis wrote re: Shrink SQL Server 2008 Database Log File Script
on 09-17-2011 1:49 PM

work in a graveyard shift. I was getting bored at work as no work here at office. So was searching through some blogs and came across your blog, great work man I liked what you wrote Inspirational and very meaningful.

lolzauva wrote re: Shrink SQL Server 2008 Database Log File Script
on 09-21-2011 5:29 AM

Thanks for taking this opportunity to discuss this. I feel fervently about this and I like learning about this subject. If possible, as you gain information, please update this blog with more information. I have found it really useful. [url=www.cheapweddingdresses-sale.co.uk]prom dresses[/url]

lolzauva wrote re: Shrink SQL Server 2008 Database Log File Script
on 09-21-2011 5:31 AM

Hello! I'm in luck today. I have been searching for this for several months now. Finally I got it all here. Thanks a lot!

diamondlia wrote re: Shrink SQL Server 2008 Database Log File Script
on 09-23-2011 2:02 AM

This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the leisure here! Keep up the good work.

diamondlia wrote re: Shrink SQL Server 2008 Database Log File Script
on 09-23-2011 2:02 AM

I really loved reading your blog. It was very well authored and easy to understand. Unlike additional blogs I have read which are really not tht good. I also found your posts very interesting. In fact after reading, I had to go show it to my friend and he enjoyed it as well!Thanks so much for this! I have not been this thrilled by a blog post for quite some time! You’ve got it, whatever that means in blogging. Anyway, You’re definitely someone that has something to say that people should hear. Keep up the wonderful job. Keep on inspiring the people

zunningdale wrote re: Shrink SQL Server 2008 Database Log File Script
on 10-13-2011 6:19 PM

I think the things you covered through the post are quiet impressive, good job and great efforts. I found it very interesting and enjoyed reading all of it…keep it up, lovely job..

zunningdale wrote re: Shrink SQL Server 2008 Database Log File Script
on 10-13-2011 6:19 PM

I think the things you covered through the post are quiet impressive, good job and great efforts. I found it very interesting and enjoyed reading all of it…keep it up, lovely job..  <a href="www.bartonwyatt.co.uk/estate-agents-surrey.php">estate agents Sunningdale</a>

ice maker wrote re: Shrink SQL Server 2008 Database Log File Script
on 11-15-2011 8:18 PM

Appreciating the time and energy you put into your site and in depth information you present. It's awesome to come across a blog every once in a while that isn't the same old rehashed material. Wonderful read! I've bookmarked your site and I'm including your RSS feeds to my Google account.http://www.cbfi-icemachine.com

taln11 wrote re: Shrink SQL Server 2008 Database Log File Script
on 11-16-2011 10:02 PM

Great information about SQL server, this really came in handy for me. Cheers

Hildegarde wrote re: Shrink SQL Server 2008 Database Log File Script
on 12-06-2011 1:27 AM

I like this concept.

Hildegarde wrote re: Shrink SQL Server 2008 Database Log File Script
on 12-13-2011 3:41 AM

I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people.

ria223 wrote re: Shrink SQL Server 2008 Database Log File Script
on 12-20-2011 7:34 PM

It’s a high-quality summary that you have written. There are a number of points however which I believe would do  better if you went into a little bit further detail than you have done. simply my opinion,plus I’m not trying  to be critical at all. If you do follow this up then I would be interested. Thanks.

www.jgsupplements.com/stevia

angelinajohn wrote re: Shrink SQL Server 2008 Database Log File Script
on 12-23-2011 6:23 AM

There are a number of points however which I believe would do  better if you went into a little bit further detail than you have done. simply my opinion,plus I’m not trying  to be critical at all. If you do follow this up then I would be interested. And please let me know about your other posts as well.<a href="www.socialcubix.com/.../android-application-development">Android App Developer</a>

pearpandas wrote re: Shrink SQL Server 2008 Database Log File Script
on 12-23-2011 1:12 PM

I love learning about sql - thanks for the tips!

www.wouldyouratherquiz.com

Watson5 wrote re: Shrink SQL Server 2008 Database Log File Script
on 01-04-2012 5:52 AM

I highly recommend EAS Simply Protein.their are many others but its the best one,..when it is used with milk it gives more better results,..

pearpandas wrote re: Shrink SQL Server 2008 Database Log File Script
on 01-05-2012 6:21 PM

I think that this is the best log file script that I've worked with!

pearpandas wrote re: Shrink SQL Server 2008 Database Log File Script
on 01-10-2012 1:40 PM

This is one of the best database log file scripts that there is!

It support wrote re: Shrink SQL Server 2008 Database Log File Script
on 01-17-2012 2:15 AM

Pretty cool post..It was a nice and interesting post.. thanks for sharing this with us!it’s my first visit..<a href="windows7vswindows8.com/">Windows 7 vs Windows 8</a>

Shrinking log file | web technical support wrote Shrinking log file | web technical support
on 01-25-2012 6:22 PM

Pingback from  Shrinking log file | web technical support

ria223 wrote re: Shrink SQL Server 2008 Database Log File Script
on 02-10-2012 4:43 AM

That's really funny indeed if you're into hockey. I used to play hockey pool back in college and I loved it. Latter on I got fat and I only have the memories now. Enjoyed passing by, nice graphics, keep yo the great work!

<a rel="follow" href="http://dellabellaphotography.com">wedding photography CT</a>

Stevesmith wrote re: Shrink SQL Server 2008 Database Log File Script
on 02-28-2012 5:50 AM

It’s a luxury digest that you have printed. There are a amount of points though which I suppose would do better if you went into a little small piece more point than you have done.<a href="www.qoutz.com/holi-quotes">Hindi Holi One Liners</a> | <ahref="www.qoutz.com/mothers-day-quotes

">Hindi Mother day One Liners</a>

Stevesmith wrote re: Shrink SQL Server 2008 Database Log File Script
on 02-28-2012 5:54 AM

This piece of writing provides help out in writing your own kindness message as well as providing some thoughts set for you to use.<a href="www.qoutz.com/holi-quotes

">Hindi Holi One Liners</a> | <aref="www.qoutz.com/mothers-day-quotes

>Hindi Mother day One Liners</a>

stevencobbler wrote re: Shrink SQL Server 2008 Database Log File Script
on 03-09-2012 1:29 PM

As U an first time visitor here I can't contribute much here but I will at least give it a try

stevencobbler wrote re: Shrink SQL Server 2008 Database Log File Script
on 03-09-2012 1:30 PM

Still can't understand what went wrong thevocabularyworkshop.com

hermes birkin33 wrote re: Shrink SQL Server 2008 Database Log File Script
on 04-11-2012 2:42 AM

<a href="www.21cncoach.com/"><strong><em>coach factory outlet</em></strong></a> sell all types of Coach leather products and accessories <a href="www.21cncoach.com/">coach outlet coupons</a> at really discounted prices. Any one who <a href="www.21cncoach.com/">coach outlet store</a> would like to get a actually sumptuous purse, purse, wallet, baggage <a href="www.21cncoach.com/">coach outlet</a> or any other accessories, at significantly lower prices <a href="www.21cncoach.com/">coach factory</a> than normal, they should visit Coach outlets. <br><br>

<a href="www.store-hermesoutlet.com/"><strong><em>hermes birkin</em></strong></a> The truth is all the products <a href="www.store-hermesoutlet.com/">hermes outlet</a> which are sold at <a href="www.store-hermesoutlet.com/"><FONT color=#bb00cc>hermes outlet online</FONT></a> are of made with <a href="www.store-hermesoutlet.com/">hermes belts</a> quality standards. Some times they <a href="www.store-hermesoutlet.com/">hermes bags</a> do not sell in showrooms <a href="www.store-hermesoutlet.com/hermes-accessories-c-2.html">hermes watch bands</a> and must be removed <a href="www.store-hermesoutlet.com/hermes-bags-2012-c-21.html">hermes bags for sale</a> to make way for new <a href="www.store-hermesoutlet.com/hermes-birkin-c-7.html">cheap hermes birkin bag</a> arrivals hence are shifted to <a href="www.store-hermesoutlet.com/hermes-garden-party-c-13.html">hermes garden party bag</a> for selling at discounted prices. Some <a href="www.store-hermesoutlet.com/hermes-lindy-bags-c-18.html">hermes lindy bag</a> pieces that get damaged and defected <a href="www.store-hermesoutlet.com/hermes-sokelly-bags-c-19.html">hermes so kelly</a> during producing are also supplied to <a href="www.store-hermesoutlet.com/hermes-wallets-c-20.html">hermes wallets</a> for sell on cost to cost basis. There is nothing wrong with products.

hermes birkin33 wrote re: Shrink SQL Server 2008 Database Log File Script
on 04-11-2012 2:43 AM
hermes birkin wrote re: Shrink SQL Server 2008 Database Log File Script
on 05-10-2012 12:04 PM

oh my!! i love you so much!!Thank you so much.

Resources much like the one anyone reveal here are going to be very cooperative in my opinion! I will certainly post one of the links to this page on our blog. More than likely my guests will quickly realize that quite significant.

http://www.ahhermesbags.com/ birkin bag

qsbcl71 wrote re: Shrink SQL Server 2008 Database Log File Script
on 07-05-2012 8:58 AM

This information provided by you is very constructive for correct planning. I like to take this chance to state that i really like your post.

qsbcl71 wrote re: Shrink SQL Server 2008 Database Log File Script
on 07-05-2012 9:00 AM

This information provided by you is very constructive for correct planning. I like to take this chance to state that i really like your post.

bobbyhull wrote re: Shrink SQL Server 2008 Database Log File Script
on 07-13-2012 5:05 AM
ganqoakley wrote re: Shrink SQL Server 2008 Database Log File Script
on 08-07-2012 9:49 PM

http://www.vaultoakley.info/new-arrival-oakleys-c-89.html">www.vaultoakley.info/new-arrival-oakleys-c-89.html new arrival oakleys

www.raybanswayfarer2012.com

http://www.oakleyshut.net Oakley Vault

http://www.vaultoakley.info/oakley-active-sunglasses-c-90.html">www.vaultoakley.info/oakley-active-sunglasses-c-90.html Oakley Active Glasses

www.raybanswayfarer2012.com Ray Ban Wayfarer

http://www.oakleyshut.net

http://www.vaultoakley.info/oakley-lifestyle-glasses-c-91.html">www.vaultoakley.info/oakley-lifestyle-glasses-c-91.html oakley lifestyle sunglasses

http://www.vaultoakley.info oakley vault

www.raybanswayfarer2012.com/ray-ban-sunglasses-c-8.html ray ban sunglasses

http://www.oakleyshut.net Oakley Sunglasses

http://www.vaultoakley.info

sunny002 wrote re: Shrink SQL Server 2008 Database Log File Script
on 10-01-2012 12:15 PM

this is great website and found lot of good information out here.

suzi

http://todaytechworld.com

medicalbillingandcodingjobs.biz

cheapbeatsss wrote re: Shrink SQL Server 2008 Database Log File Script
on 11-08-2012 2:47 AM

it's great ! looking forward to reading new articles. Keep up the good work!

omrbcl123 wrote re: Shrink SQL Server 2008 Database Log File Script
on 01-28-2013 6:54 AM

You know, a lot of individuals are hunting around for this information, you could aid them greatly.

omrbcl123 wrote re: Shrink SQL Server 2008 Database Log File Script
on 01-28-2013 6:55 AM

You know, a lot of individuals are hunting around for this information, you could aid them greatly.

ice machine wrote re: Shrink SQL Server 2008 Database Log File Script
on 06-03-2013 4:15 AM

ow is usefull for me

ice machine wrote re: Shrink SQL Server 2008 Database Log File Script
on 06-03-2013 4:16 AM

thank you

councilxvb32 wrote re: Shrink SQL Server 2008 Database Log File Script
on 04-15-2014 10:48 PM

Many utilize a fibreglass human body, additionally, on the inner use a soft top covering. It really is predetermined with a pair of trolley wheels certainly, which are made for extensive vacation and difficult geography.

Cheap ATVs

Kids Scooters

Kids atvs 250cc

Kids ATVs 110cc

four wheelers

www.scootersmotorcyclesus.com

http://mega4wheelers.webs.com/

Shrinking Log File | Click & Find Answer ! wrote Shrinking Log File | Click &amp; Find Answer !
on 05-18-2014 5:52 PM

Pingback from  Shrinking Log File | Click & Find Answer !

the cufflinks guided missiles lyrics wrote the cufflinks guided missiles lyrics
on 10-09-2014 5:01 PM

Shrink SQL Server 2008 Database Log File Script - Ryan's Blog - Extended64 - The 64-Bit Windows Community

www.yellowpages.com wrote www.yellowpages.com
on 11-06-2014 9:45 AM

Shrink SQL Server 2008 Database Log File Script - Ryan's Blog - Extended64 - The 64-Bit Windows Community

washer & dryer hook-ups wrote washer & dryer hook-ups
on 11-26-2014 1:28 AM

Shrink SQL Server 2008 Database Log File Script - Ryan's Blog - Extended64 - The 64-Bit Windows Community

Please Sign in or Join to share your comments!
Copyright © Extended64.com, 2009. All rights reserved.