We are using MSSQL Server and our application has heavy data exchange every day; approx. 20K rows new data per day and the database “Log file size” keeps increasing likewise. We delete the data after processing to keep the DB size under control, however the “DB Log file” keeps on increasing.
We are manually executing following script to shrink “DB Log file” size. Also only DB owner can execute this process.
Is there permanent fix to auto-control the “DB Log file” size? Let’s say, we want it to allocate 4GB max. It should auto-wipe out the older logs.
USE db1;
GO
ALTER DATABASE db1
SET RECOVERY SIMPLE;
GO
--first parameter is log file name and second is size in MB
DBCC SHRINKFILE (db1_log, 999);
ALTER DATABASE db1
SET RECOVERY FULL;
GO
Regards, Raj