Skip to main content

Posts

Showing posts from August, 2016

Shrink all SQL Server databases transaction log files

PROBLEM: You want to shrink all SQL Server databases  transaction   log files to clean up some space SOLUTION: Use the following script to shrink all databases transaction log files. You can use it also as a maintenance job using SQL Server Agent DECLARE   @Log_name   VARCHAR ( 1000 ) DECLARE   @Db_name   VARCHAR ( 1000 ) DECLARE   @Recovery_model_desc   VARCHAR ( 1000 ) DECLARE   @SQL   nvarchar ( 2000 ) DECLARE   @ParmDefinition   nvarchar ( 1000 ) DECLARE   @SizeAfter   int DECLARE   db_cursor   CURSOR   FOR SELECT         F . NAME   AS   [LOG_NAME] ,         DB . NAME   AS   [DB_NAME] ,         DB . RECOVERY_MODEL_DESC   AS   [RECOVERY_MODEL_DESC] FROM         MASTER . SYS . MASTER_FILES   F ...