- Compressed log and database file size / * - Special note Please follow the steps, do not perform the previous steps, please do not do the following steps may not damage your database. - * / 1. Clear Log Dump Transaction library name With no_log 2. Truncated transaction log: Backup log database name with no_log 3. Shrinkage database file (if not compressed, database files do not reduce Enterprise Manager - Right click on the database you want to compress - All Tasks - Shrink Database - Shrink file - Select log file - Select shrink to XXM in the shrink mode, here will give a minimum M number to be contracted, enter this number directly, determine it - select data file - The contraction mode is selected to shrink to XXM, which gives a minimum number of M numbers that are allowed to shrink. You can enter this number directly. If you can use the SQL statement, you can use the SQL statement to complete - shrink Database DBCC ShrinkDatabase (Customer Data) - Shrink Specify data files, 1 is the file number, you can query: select * from sysfiles dbcc shrinkfile (1) 4. In order to maximize the loan log file (if it is SQL 7.0, this step can only be done in the query analyzer ) A. Separate Database: Enterprise Manager - Server - Database - Right - Right - Separate Database B. Delete Log Files in My Computer C. Additional Database: Enterprise Manager - Server - Database - Right - Right - - Additional Database Generates New Log, Size only 500 k or with code: The following example is separated, and then one of the PUBs is attached to the current server. A. Separate EXEC SP_DETACH_DB @dbname = 'Pubs' B Delete log file c. Additional EXEC SP_ATTACH_SINGLE_FILE_DB @dbname = 'pubs', @physname = 'c: / program files / microsoft SQL Server / MSSQL / DATA / PUBS.MDF' 5. In order to automatically shrink automatically, do the following settings : Enterprise Manager - Server - Right-click Database - Properties - Options - Select "Auto Shrink" - SQL Statement Setting: EXEC SP_DBOPTION 'Database Name', 'AutoShrink', 'True' 6. If you want to Do not let the log growth Great Enterprise Manager - Server - Right-click Database - Property - Transaction Log - Limit the file growth to XM (x is your maximum data file size) - SQL statement setting mode: Alter Database Database name modify file (name = logical file name, maxsize = 20)