MS Sqlserver 2000 transaction log shrink step

First, review the transaction log size prior to the shrinking process.

USE [YourDatabaseNameHere]
GO
SELECT *
FROM sysfiles
WHERE name LIKE '%LOG%'
GO
 

Second, set the database recovery model to 'simple'. 

USE [YourDatabaseNameHere]
GO
ALTER DATABASE [YourDatabaseNameHere] SET RECOVERY SIMPLE
GO
 

Third, issue a checkpoint against the database to write the records from the transaction log to the database.

USE [YourDatabaseNameHere]
GO
CHECKPOINT
GO
 

Fourth, truncate the transaction log.

USE [YourDatabaseNameHere]
GO
BACKUP LOG [YourDatabaseNameHere] WITH NO_LOG
GO
 

Fifth, record the logical file name for the transaction log to use in the next step.

USE [YourDatabaseNameHere]
GO
SELECT Name
FROM sysfiles
WHERE name LIKE '%LOG%'
GO 

Sixth, to free the unused space in your transaction log and return the space back to the operating system, shrink the transaction log file.

USE [YourDatabaseNameHere]
GO
DBCC SHRINKFILE ([FileNameFromPreviousStep], [NeededFileSize])
GO
 

Seven, review the database transaction log size to verify it has been reduced.

USE [YourDatabaseNameHere]
GO
SELECT *
FROM sysfiles
WHERE name LIKE '%LOG%'
GO

Next Steps

  • Review your key SQL Server databases to determine if the transaction log growth is out of control.
  • Review this code and modify it for one of your databases.
  • Once the scripts are modified, test the scripts in a test environment to ensure they meet your needs.
  • Schedule time to shrink your databases and communicate the configuration changes.
  • Continue to monitor the database sizes and the available disk space on your servers.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值