by
Venkata Koppaka
| Aug 16, 2010
To just shrink the size of a database log file, use the following code:
| 1 | backup log database_name with truncate_only |
| 2 | dbcc shrinkfile (database_log_name) |
| 3 | GO |
The backup log statement marks all of the transactions listed in the log Inactive, and then the dbcc shrinkfile command will remove the Inactive transactions from the file, thereby shrinking the size of the database.
If the database_log_name is unknown, you can also use the File_ID instead of the name, and that can be found by using:
when you are in the desired database that you want to delete the log from.
There is a shrink database command called dbcc shrinkdatabase (database_name) that takes a database name as an input and will attempt to shrink the size of the database files in the same manor as described above.
Hope this helps,
Cheers,
Venkata