Deru Knowledgebase
Search:     Advanced search
Browse by category:
Contact Us

Shrinking the Transaction Log in SQL Server 2000 with DBCC SHRINKFILE

Add comment
Views: 893
Votes: 0
Comments: 0
Posted: 13 Aug, 2009
by: Nini E.
Updated: 08 Sep, 2009
by: Joseph S.
Here I am describing, how to shrink the log file in SQL Server 2000. A shrink operation attempts to shrink the file immediately. However, in some circumstances it may be necessary to perform additional actions before the log file is shrunk to the desired size.

When DBCC SHRINKFILE is run, SQL Server 2000 shrinks the log file by removing as many virtual log files as it can to attempt to reach the target size. If the target file size is not reached, SQL Server places dummy log entries in the last virtual log file until the virtual log is filled and moves the head of the log to the beginning of the file. The following actions are then required to complete the shrinking of the transaction log:
  1. You must run a BACKUP LOG statement to free up space by removing the inactive portion of the log.
  2. You must run DBCC SHRINKFILE again with the desired target size until the log file shrinks to the target size.
The following example demonstrates this with the "test" database and attempts to shrink the "test_log" file to 2 MB:

  1. Run this code:
                    DBCC SHRINKFILE(test_log, 10000)           

            NOTE: If the target size is not reached, proceed to the next step.

       2. Run this code if you want to truncate the transaction log and not keep a backup of the transaction log. Truncate_only invalidates your transaction log backup sequence. Take a full backup of your database after you perform backup log with truncate_only:

                     BACKUP LOG test WITH TRUNCATE_ONLY

The transaction log has now been shrunk to the target size.
Others in this Category
document How to find uptime of a windows/Linux server ?
document Adding SPF Record in the Windows DNS server
document Monitoring and terminating runaway process in Windows
document FTP login problem in Windows Plesk platform
document Schedule MSSQL backup in 2005 with maintenance clean up task
document To open the port range in windows firewall
document How to create a new user on Windows 2000 & 2003 Server?
document How to password protect a folder in IIS?
document How to configure SQL Server 2005 to allow remote connections
document HOW TO: Create a New Zone on a DNS Server in Windows Server 2003
document How to create a new user for a database in Microsoft SQL Server 2005
document Steps to clear Browser cache
document How to clear DNS Cache



RSS