"how to shrink a database in ms sql server if the drive is full?" Code Answer

4

sql server pre 2012

backup log logname
  with truncate_only;

sql server 2012 onwards

the with_truncateonly has been removed so you should switch the recovery model to simple and revert to perform the same action.

alter database databasename
  set recovery simple;

after which, don't forget to re-instate your original recovery model!

shrinking the log

just because you've truncated the log this does not mean that the file size on disk has changed.

to reduce the file size of the log you need to issue the following command

dbcc shrinkfile (databaseloglogicalname, 1);
By Blake Chambers on May 15 2022

Answers related to “how to shrink a database in ms sql server if the drive is full?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.