Solved

Shrink logfile - meaning of this commad

Posted on 2012-03-18
3
374 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.

772 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

14 Experts available now in Live!

Get 1:1 Help Now