Diminuir o tamanho do log file em BD's SQL Server
Tinha uma BD em SQL Server cujo logfile cavalgava para o Gb de tamanho. como o conteúdo do logfile não tinha qualquer interesse, pensei "e se mostrasse a este tipo quem manda aqui e pusesse o log com um tamanho decente?".
Como estas coisas de software e computadores têm os seus caprichos, lá fui eu ao meu amigo Google para ver o que é que se dizia por aí acerca do assunto.
Encontrei a resposta e testei-a (sem esquecer o backup da praxe, que isto de trabalhar sem rede já não é para os meus nervos). Funcionou na perfeição.
Para quem quiser/precisar disto, aqui fica a dica, encontrada aqui (mas não passem à frente o backup!):
I guess that rather "truncating" the log file, you want to "shrink" the log file ?!! For this, you need a different sql statement, or if you really want to shrink it down, do the following:set the max size of the log file to say 20% of the actual database size, which should be sufficient if the option "truncate log on checkpoint" is set, use Enterprise manager for this
- close any connections to the database
- detach it (use sp_detach_db) in query analyser
- rename/delete the .ldf file(s) in Windows explorer
- attach the data (use sp_Attach_db), specifying only the .mdf file(s). This step will recreate the transaction log file with a small size :-) in query analyser