SQL2005 Empty Delete log:
Copy CodeThe code is as follows: Backup Log dnname with no_log--' Here's dnname is the name of the database you want to shrink, and notice to modify the database name below, I will no longer comment. Go DUMP transaction dnname with no_log go use Dnname DBCC shrinkfile (2) Go
SQL2008 Empty Delete log:
' Clearing the log in SQL2008 must be done in simple mode, and then back to full mode when the cleanup is complete.
Copy CodeThe code is as follows: Use [master] GO ALTER database dnname SET RECOVERY simple with no_wait GO ALTER DATABASE dnname SET RECOVERY Simple- -Simple mode go use dnname go DBCC shrinkfile (N ' Dnname_log ', one, truncateonly)
GO
' Here's dnname_log if you don't know what the name is in sys.database_files, you can query it with the following annotated statement
' Use Dnname
' GO
' SELECT file_id, Namefrom sys.database_files;
' Go use [master] GO ALTER DATABASE dnname SET RECOVERY full with no_wait GO ALTER DATABASE dnname SET RECOVERY full--Restore to end Full Mode GO
sqlserver2000 Compression Log
you can make the Jb51.ldf file very small, easy to back up the database, and so on, executed in SQL Server Query Analyzer.
Copy CodeThe code is as follows: DUMP TRANSACTION [jb51] with no_log
BACKUP LOG [jb51] with no_log DBCC shrinkdatabase ([jb51])
Clear logs for each version of the SQL database