1: Delete Log
1: Detach Database Enterprise Manager-> Server-> database-> right key-> Detach database
2: Delete log file
3: Additional database Enterprise Manager-> Server-> database-> right key-> attached database
This method generates a new log with a size of more than 520 K
And then set this database to automatically shrink
or in code:
The following example separates 77169database and then attaches a file in 77169database to the current server.
EXEC sp_detach_db @dbname = '77169database'
EXEC sp_attach_single_file_db @dbname = '77169database',
@physname = 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\77169database.mdf'
2: Empty the Log
DUMP TRANSACTION Library name with NO_LOG
Again
Enterprise Manager--right you want to compress the database--All tasks--shrink the database--Shrink the file--select log file--in the contraction of the choice of contraction to XXM, here will give a allow to shrink to the minimum m number, directly enter this number, OK.
3: Don't Let it grow
Enterprise Manager-> Server-> database-> properties-> transaction log-> limit file growth to 2M
Automatically shrink the log, or you can use the following statement
alter DATABASE 数据库名
SETAUTO_SHRINK ON
The failover model is simple, with the statement
USE MASTER
GO
ALTER DATABASE 数据库名 SET RECOVERY SIMPLE
GO
----------------------------------------------------------
Truncate transaction log:
BACKUP LOG { database_name | @database_name_var }
{
[ WITH
{ NO_LOG | TRUNCATE_ONLY } ]
}
--Compressed log and database file size
/*--Special attention
Please follow the steps and do not follow the steps above.
Otherwise, you may damage your database.
--*/