I have a limited space in the server and i have to remove transactions periodically. Moreover, I use below query that answered in this StackOverFlow question:How do you clear the SQL Server transaction log?
USE db;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE db
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (db_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE db
SET RECOVERY FULL;
GO
However, i want this simple query to be much more advanced and put below conditions.
- Remove Transaction Logs When 10% free space remained from the
db_Log
(100 mb free 900 mb used) - Transaction Logs file Must have a fixed size(1GB)