Solved

Shrink logfile - meaning of this commad

Posted on 2012-03-18
3
376 Views
Last Modified: 2012-04-02
I found this command:

DBCC SHRINKFILE(<TransactionLogName>, 1)
BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY
DBCC SHRINKFILE(<TransactionLogName>, 1)

Does this truncate the log file or shrink it??not sure what the commands exactly mean.
0
Comment
Question by:Camillia
3 Comments
 
LVL 10

Assisted Solution

by:sqlservr
sqlservr earned 167 total points
ID: 37736676
when the database is i full recoery mode
DBCC SHRINKFILE(<TransactionLogName>, 1)

this command shrinks the log file to 1 MB.

BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY
takes the backup of log file using truncate command

DBCC SHRINKFILE(<TransactionLogName>, 1)

this command shrinks the log file to 1 MB.


note:
if you are not intrested in shrinking the log file (ldf) , then make a habbit of  taking the transaction log file backup
0
 
LVL 25

Accepted Solution

by:
jogos earned 167 total points
ID: 37737089
When taking a transactionlog backup the space in the file is freed to be reused , but the file won't shrink. And that's a good thing while allocationg space is time consuming and always allocating and deallocating space will fragment your transactionlog on disk.
It's better to see what's a decent 'maximum usage' of your transaction log and allocate that space for it so it never has to expand and also does not have tor shrink either.
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 166 total points
ID: 37738830
Does this truncate the log file or shrink it??not sure what the commands exactly mean.
It means:
1.  They are not using SQL Server 2008 as "WITH TRUNCATE_ONLY" is thankfully no longer supported on that version.
2.  They are fragmenting the database.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now