Use script to narrow the database log

xiaoxiao2021-03-06  40

Leisure, refer to SQLServer's help file, write the following script, can truncate logs to achieve the purpose of narrowing the file. Have a space, you can test the effect on your own SQL Server. . . :) Perhaps the logs caused by some cases have no great effect, which can be exchanged with each other.

- Execute the following script (using Query Analyzer) declare @dbname varchar (50) in the MASTER database declare temp_cur cursor scroll for select name from sysdatabasesopen temp_curfetch first from temp_cur into @dbnamewhile @@ fetch_status = 0 begin exec ( 'backup log' @ dbname 'with no_log') exec ( 'dbcc shrinkdatabase (' @ dbname ')') exec ( 'dbcc checkcatalog (' @ dbname ')') exec ( 'dump transaction' @ dbname 'with no_log') Fetch next from temp_cur @dbnamendclose temp_curdeallocate temp_cur

转载请注明原文地址:https://www.9cbs.com/read-64919.html

New Post(0)