How to shrink a MSSQL log file
No more disc space on your SQL server? There's a change that the log files are too big. This guide will show you how to stop using the log files and errase them. Pay attention, you cannot restore these files and must make a backup before you begin!!!!
What You'll Need
- SQL
- shrink db
- ldf
- log file shrink
- database
Tips
לשים לב לשמות הקבצים מפקודות ה- select
Warning
לא לבצע בלי גיבויי !!!
Steps
- 1
Step 1
יש להעביר את בסיס הנתונים למצב גיבויי "simple" - ניתן לעשות זאת דרך הממשק, או דרך פקודת ה- SQL use dbname select name,recovery_model_desc from sys.databases - יחזיר את שמות הקבצים לכווץ ומצבם lter database dbname SET Recovery simple -ישנה את בסיס הנתונים הנבחר. - 2
Step 2
הכווץ עצמו - dbcc shrinkfile ('dbname_log) - 3
Step 3
עכשיו אפשר לבדוק את הגודל - select name,size from sys.database_files