How to delete the MSSQL transaction log.

How to delete the MSSQL transaction log.

If your transaction log is big or too much large. it will utilize your space and other issue might be there, so you need to clean up the transaction log time to time. Follow the following steps and clean your LOG size.

1)  first take log backup

-- Backup on Drive
BACKUP LOG TESTDB TO DISK='d:\TEMP.bak' with init


-- Backup and Delete file

BACKUP LOG TESTDB TO DISK='NUL'

 

2) Shrink your Database.


USE TESTDB
GO
DBCC SHRINKFILE ('TESTDB_log', EMPTYFILE);
GO

From GUI mode: Rclick  DB ==> Task ==> Shirinks ==> Database ==> specify size and press OK

3) Now see your log and file size.


SELECT name AS [File Name] , file_id, physical_name AS [Physical Name],
size/128 AS [Total Size in MB],
size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0
AS [Available Space In MB]
FROM sys.database_files;

MSDN:
You can reduce the default size of an empty file by using DBCC SHRINKFILE target_size. For example, if you create a 5-MB file and then shrink the file to 3 MB while the file is still empty, the default file size is set to 3 MB. This applies only to empty files that have never contained data.

10 Responses

  1. Wonderful goods from you, man. I’ve understand your stuff previous to and you’re just too excellent.
    I really like what you have acquired here, really like what you are stating and
    the way in which you say it. You make it entertaining and you
    still take care of to keep it sensible. I cant wait
    to read much more from you. This is really a tremendous website.

  2. Hello I am so delighted I found your blog page, I really found you by error, while I was
    searching on Bing for something else, Nonetheless I am here
    now and would just like to say many thanks for a marvelous post and a all round entertaining blog
    (I also love the theme/design), I don’t have time to read it all at the minute but I have saved it and also added your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the fantastic job.

  3. If you would like to increase your knowledge simply keep visiting this web page and be updated with the most recent news update posted
    here.

  4. What i don’t understood is in reality how you are now not actually much more smartly-liked than you might be now. You are very intelligent. You understand therefore considerably with regards to this topic, produced me in my opinion believe it from so many numerous angles. Its like women and men aren’t interested unless it’s something to accomplish with Lady gaga! Your individual stuffs excellent. Always take care of it up!

  5. Excellent pieces. Keep writing such kind of information on your
    blog. Im really impressed by your blog.
    Hey there, You have performed an excellent job.
    I will definitely digg it and in my opinion suggest to my friends.
    I am confident they will be benefited from this web site.

  6. I will immediately grab your rss as I can’t find your email subscription link or e-newsletter service. Do you’ve any?
    Please let me recognize so that I may subscribe. Thanks.

  7. I don’t even know how I ended up here, but I thought this post was great. I don’t know who you are
    but definitely you’re going to a famous blogger if you are not already 😉 Cheers!

  8. Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your blog?

    My blog site is in the exact same area of interest as yours and my visitors
    would genuinely benefit from a lot of the information you present here.
    Please let me know if this okay with you. Appreciate it!

  9. Wow, that’s what I was seeking for, what a data! present here at this web site, thanks admin of this site.

  10. Thank you guys you can share and use RSS, Due to some personal reason i was not able to update continuously .. Bt going forward i will start updating my blog again.. Cheers !

Leave a comment