| 
					
				 | 
			
			
				@@ -63,6 +63,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "cell_type": "code", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "execution_count": null, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "source": [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "SET NOCOUNT ON\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "DECLARE @SQL VARCHAR (8000), @log_reuse_wait tinyint, @log_reuse_wait_desc nvarchar(120), @dbname sysname, @database_id int, @recovery_model_desc varchar (24)\r\n", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -125,7 +126,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "    BEGIN\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "        select 'Is '+ @recovery_model_desc +' recovery model the intended choice for your database? Review recovery models and determine if you need to change it. https://docs.microsoft.com/sql/relational-databases/backup-restore/recovery-models-sql-server'\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "        select 'To truncate the log consider performing a transaction log backup on database ''' + @dbname+ ''' which is in ' + @recovery_model_desc +' recovery model. Be mindful of any existing log backup chains that could be broken' as Recommendation\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                "        select 'BACKUP LOG [' + @dbname + '] TO DISK = ''some_volume:\\some_folder' + @dbname + '_LOG.trn''' as BackupLogCommand\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "        select 'BACKUP LOG [' + @dbname + '] TO DISK = ''some_volume:\\some_folder\\' + @dbname + '_LOG.trn''' as BackupLogCommand\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "    END\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "    else if (@log_reuse_wait = 3)\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "    BEGIN\r\n", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -184,14 +185,12 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "END\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "CLOSE no_truncate_db\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                "DEALLOCATE no_truncate_db\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                "" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "DEALLOCATE no_truncate_db\r\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "outputs": [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "metadata": { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "azdata_cell_guid": "9056554c-ad23-446e-9225-daa19154731a" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "outputs": [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "execution_count": null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "cell_type": "markdown", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -216,6 +215,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "cell_type": "code", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "execution_count": null, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "source": [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "SELECT bs.database_name\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ", backuptype = CASE \r\n", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -242,11 +242,10 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "AND bs.backup_start_date > DATEADD(month, -2, sysdatetime()) --only look at last two months\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "ORDER BY bs.database_name asc, bs.Backup_Start_Date desc;" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "outputs": [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "metadata": { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "azdata_cell_guid": "f351810c-19e0-4b39-aa1b-01fced961829" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "outputs": [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "execution_count": null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "cell_type": "markdown", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -306,8 +305,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "### Utility script for recommended actions\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                "These steps can be partly-automated by running this T-SQL script which will identify logs files that using a large percentage of disk space and suggest actions:\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                "" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "These steps can be partly-automated by running this T-SQL script which will identify logs files that using a large percentage of disk space and suggest actions:\r\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "metadata": { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "azdata_cell_guid": "7fdd7c75-6904-4ec1-89c8-459aef29b1bb" 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -315,6 +313,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "cell_type": "code", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "execution_count": null, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "source": [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "DECLARE @log_reached_disk_size BIT = 0\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "\r\n", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -377,11 +376,10 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "END" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "outputs": [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "metadata": { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "azdata_cell_guid": "1c9389f3-6389-4bfa-8a96-b57a5fd3a834" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "outputs": [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "execution_count": null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "cell_type": "markdown", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -396,6 +394,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "cell_type": "code", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "execution_count": null, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "source": [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "SELECT db_name(database_id) DbName,\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "       name LogName,\r\n", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -445,11 +444,10 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "ELSE\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "    SELECT 'Found no files that have reached max log file size' as Findings" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "outputs": [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "metadata": { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 "azdata_cell_guid": "2b57ea05-f10d-46a0-9c4e-ef93e48b5222" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "outputs": [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "execution_count": null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "cell_type": "markdown", 
			 |