Solved

Shrink logfile - meaning of this commad

Posted on 2012-03-18
3
384 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

679 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