Solved

Shrink logfile - meaning of this commad

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DTS Connection Failed 7 70
Help Required 3 97
Update a text value in another table 10 40
Sql server get data from a usp to use in a usp 5 16
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…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

803 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