I am confused about SQL Server t-Log file size growth (.ldf file). I analyzed various blogs/topics by DBA's some recommending Log file Shrink while some advised not to do so. Here is what I used to follow:
Take Database in Full mode if its not already in it.
Shrink Log files if not enough memory freed then move to next step.
- De-Attach Database. (sometimes it went in Single Mode and no matter what deadlock process I kill , it will never come in multi-user mode again. BIG PROBLEM!!! )
- move .ldf file to other location and Restore mdf file only.
This was not a recommended technique so I surfed to following script i.e. reducing Virtual Log File (VLF) to free unused space:
USE dbname
BACKUP LOG dbname TO DISK = 'C:\x\dbname.trn'
--First param below is fileno for log file, often 2. Check with sys.database_files
--Second is desired size, in MB.
DBCC SHRINKFILE(2, 500)
DBCC SQLPERF(LOGSPACE) --Optional
DBCC LOGINFO --Optional
Now repeate above commands as many times as needed!
I am not sure if is the VLF script professionally recommended to try at Production Environment where Down time cannot be afforded. Please advise how should I move forward.