Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 51469 |  Welcome, Guest!   Register  Login
 Home > Blogs > SQL Server > How To Shrink Database Log File In Sql Server ...
Akshayblevel

How To Shrink Database Log File In Sql Server

 Blog author: Akshayblevel | Posted on: 8/6/2012 | Category: SQL Server Blogs | Views: 936 | Status: [Member] | Points: 75 | Alert Moderator   
Ads

Select size of database files before shrink 

SELECT Name AS Logical_Name,(size*8)/1024 SizeMB 
FROM sys.master_files
WHERE DB_NAME(database_id) = 'MyDB'
GO


USE MyDB;
GO

Truncate the log by changing the database recovery model to SIMPLE.

ALTER DATABASE MyDB
SET RECOVERY SIMPLE WITH NO_WAIT;
GO

Shrink the truncated log file to 1 MB.

DBCC SHRINKFILE(MyDB_log, 1); 
GO

Reset the database recovery model.

ALTER DATABASE MyDB
SET RECOVERY FULL WITH NO_WAIT;
GO

Select size of database files After shrink 

SELECT Name AS Logical_Name, (size*8)/1024 SizeMB FROM sys.master_files
WHERE DB_NAME(database_id) = 'MyDB'
GO



Found interesting? Add this to:



 More Blogs from Akshayblevel

     More ...

    About akshay patel

    Experience:5 year(s)
    Home page:http://www.dotnetfunda.com
    Member since:Friday, March 12, 2010
    Level:Starter
    Status: [Member]
    Biography:

     Responses

    Deepika.Gandhi
    Posted by: Deepika.Gandhi | Posted on: 8/27/2012 | Level: Starter | Status: [Member] | Points: 15 | Alert Moderator 

    Good one!

    Sarah
    Posted by: Sarah | Posted on: 9/7/2012 | Level: Starter | Status: [Member] | Points: 15 | Alert Moderator 

    Thanks for all the information,it was very helpful and i really like that you are providing information on .net training ,being enrolled in .net freshers training with projects live training http://www.wiziq.com/course/57-fresher-training-projects i was looking for such .net fresher training to assist me and your information helped me a lot.Really like that you are providing such information . Thanks.

    sarah

    >> Write Response - Respond to this post and get points

    More Blogs

    About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
    General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
    Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/19/2013 11:03:52 AM