{"id":853,"date":"2009-05-24T14:32:00","date_gmt":"2009-05-24T14:32:00","guid":{"rendered":"\/blogs\/paul\/post\/New-script-how-much-data-will-the-next-log-backup-include.aspx"},"modified":"2018-08-31T16:06:23","modified_gmt":"2018-08-31T23:06:23","slug":"new-script-how-much-data-will-the-next-log-backup-include","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/","title":{"rendered":"New script: how much data will the next log backup include?"},"content":{"rendered":"<p>\n<font face=\"verdana,geneva\" size=\"2\">About a year ago, I blogged a cool script that would work out how much of a database has changed since the last full backup &#8211; i.e. how big will the next differential backup be. You can find that script at <\/font><a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-of-the-database-has-changed-since-the-last-full-backup\/\"><font face=\"verdana,geneva\" size=\"2\">New script: How much of the database has changed since the last full backup?<\/font><\/a><font face=\"verdana,geneva\" size=\"2\">. I&#39;m in the middle of writing a script that will tell you how big your next log backup will be, and as part of it, I need a way to determine how many extents from minimally logged operations will be included in the next log backup. I thought it might be useful to someone so I tidied it up and here it is for you to play with. It&#39;s almost the same as the previous script I published. <\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">The code below creates a function and a stored procedure. The basic idea behind the code is as follows: <\/font>\n<\/p>\n<blockquote dir=\"ltr\" style=\"margin-right: 0px\">\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">For each online data file in the database<br \/>\n\t&nbsp;&nbsp;&nbsp;For each GAM interval in the file<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Crack the&nbsp;ML map page using DBCC PAGE<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Interpret the&nbsp;ML bitmap to aggregate the changed extents<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Add the sum to the total changed extents for the database<br \/>\n\t&nbsp;&nbsp;&nbsp;End<br \/>\n\tEnd<br \/>\n\tReport results<\/font>\n\t<\/p>\n<\/blockquote>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">There&#39;s a function that I create in msdb call <font face=\"courier new,courier\">SQLskillsConvertToExtents<\/font> that cracks some of the <font face=\"courier new,courier\">DBCC PAGE<\/font> output, and the main procedure is called <font face=\"courier new,courier\">sp_SQLskillsMLChangedData<\/font> and it created as a system object in master. I tried making it a table-valued function but you can&#39;t do things like <font face=\"courier new,courier\">INSERT-EXEC<\/font> in a function, and that&#39;s required for processing the <font face=\"courier new,courier\">DBCC PAGE<\/font> output. So &#8211; create your own wrapper function or whatever to use it. The interface\/output is: <\/font>\n<\/p>\n<p><font face=\"Courier New\" size=\"2\"><\/p>\n<blockquote dir=\"ltr\" style=\"margin-right: 0px\"><p>\n\tEXEC sp_SQLskillsMLChangedData &#39;testdb&#39;;<br \/>\n\tGO <\/p>\n<p>\n\tTotal Extents Changed Extents Percentage Changed<br \/>\n\t&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n\t355&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;153&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 43.1\n\t<\/p>\n<\/blockquote>\n<p><\/font><font face=\"Verdana\" size=\"2\">Anyway &#8211; here it is. You can download it in a zip file from <a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/content\/binary\/sqlskillsmlchangeddata.zip\">SQLskillsMLChangedData.zip (2.50KB)<\/a>. Enjoy!<\/font> <font face=\"Courier New\" size=\"2\"><\/p>\n<blockquote dir=\"ltr\" style=\"margin-right: 0px\">\n<p>\n\t\/*============================================================================<br \/>\n\t&nbsp;&nbsp; File: SQLskillsMLChangedData.sql\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; Summary: This script creates a system-wide SP SQLskillsMLChangedData that<br \/>\n\t&nbsp;&nbsp; works out what percentage of a database has been changed by minimally<br \/>\n\t&nbsp;&nbsp; logged operations since the last log backup.\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; Date: May 2009\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; SQL Server Versions:<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10.0.2531.00 (SS2008 SP1)<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9.00.4035.00 (SS2005 SP3)<br \/>\n\t&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t&nbsp;&nbsp; Copyright (C) 2009 Paul S. Randal, SQLskills.com<br \/>\n\t&nbsp;&nbsp; All rights reserved.\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; For more scripts and sample code, check out<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href=\"https:\/\/www.sqlskills.com\/\">http:\/\/www.sqlskills.com\/<\/a>\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; You may alter this code for your own *non-commercial* purposes. You may<br \/>\n\t&nbsp;&nbsp; republish altered code as long as you give due credit.\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; THIS CODE AND INFORMATION ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF<br \/>\n\t&nbsp;&nbsp; ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED<br \/>\n\t&nbsp;&nbsp; TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\/OR FITNESS FOR A<br \/>\n\t&nbsp;&nbsp; PARTICULAR PURPOSE.<br \/>\n\t============================================================================*\/\n\t<\/p>\n<p>\n\t&#8212; Create the function in MSDB<br \/>\n\t&#8212;<br \/>\n\tUSE msdb;<br \/>\n\tGO\n\t<\/p>\n<p>\n\tIF EXISTS (SELECT * FROM sys.objects WHERE NAME = &#39;SQLskillsConvertToExtents&#39;)<br \/>\n\t&nbsp;&nbsp; DROP FUNCTION SQLskillsConvertToExtents;<br \/>\n\tGO\n\t<\/p>\n<p>\n\t&#8212; This function cracks the output from a DBCC PAGE dump<br \/>\n\t&#8212; of an allocation bitmap. It takes a string in the form<br \/>\n\t&#8212; &quot;(1:8) &#8211; (1:16)&quot; or &quot;(1:8) -&quot; and returns the number<br \/>\n\t&#8212; of extents represented by the string. Both the examples<br \/>\n\t&#8212; above equal 1 extent.<br \/>\n\t&#8212;<br \/>\n\tCREATE FUNCTION SQLskillsConvertToExtents (<br \/>\n\t&nbsp;&nbsp; @extents VARCHAR (100))<br \/>\n\tRETURNS INTEGER<br \/>\n\tAS<br \/>\n\tBEGIN<br \/>\n\t&nbsp;&nbsp; DECLARE @extentTotal INT;<br \/>\n\t&nbsp;&nbsp; DECLARE @colon INT;<br \/>\n\t&nbsp;&nbsp; DECLARE @firstExtent INT;<br \/>\n\t&nbsp;&nbsp; DECLARE @secondExtent INT; <br \/>\n\t&nbsp;&nbsp; SET @extentTotal = 0;<br \/>\n\t&nbsp;&nbsp; SET @colon = CHARINDEX (&#39;:&#39;, @extents);\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; &#8212; Check for the single extent case<br \/>\n\t&nbsp;&nbsp; &#8212;<br \/>\n\t&nbsp;&nbsp; IF (CHARINDEX (&#39;:&#39;, @extents, @colon + 1) = 0)<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET @extentTotal = 1;<br \/>\n\t&nbsp;&nbsp; ELSE<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; We&#39;re in the multi-extent case<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BEGIN<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET @firstExtent = CONVERT (INT,<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SUBSTRING (@extents, @colon + 1, CHARINDEX (&#39;)&#39;, @extents, @colon) &#8211; @colon &#8211; 1));<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET @colon = CHARINDEX (&#39;:&#39;, @extents, @colon + 1);<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET @secondExtent = CONVERT (INT,<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SUBSTRING (@extents, @colon + 1, CHARINDEX (&#39;)&#39;, @extents, @colon) &#8211; @colon &#8211; 1));<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET @extentTotal = (@secondExtent &#8211; @firstExtent) \/ 8 + 1;<br \/>\n\t&nbsp;&nbsp; END\n\t<\/p>\n<p>\n\tRETURN @extentTotal;<br \/>\n\tEND;<br \/>\n\tGO\n\t<\/p>\n<p>\n\tUSE master;<br \/>\n\tGO\n\t<\/p>\n<p>\n\tIF OBJECT_ID (&#39;sp_SQLskillsMLChangedData&#39;) IS NOT NULL<br \/>\n\t&nbsp;&nbsp; DROP PROCEDURE sp_SQLskillsMLChangedData;<br \/>\n\tGO\n\t<\/p>\n<p>\n\t&#8212; This SP cracks all minamally-logged bitmap pages for all online<br \/>\n\t&#8212; data files in a database. It creates a sum of changed extents<br \/>\n\t&#8212; and reports it as follows (example small msdb):<br \/>\n\t&#8212; <br \/>\n\t&#8212; EXEC sp_SQLskillsMLChangedData &#39;msdb&#39;;<br \/>\n\t&#8212; GO<br \/>\n\t&#8212;<br \/>\n\t&#8212; Total Extents Changed Extents Percentage Changed<br \/>\n\t&#8212; &#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n\t&#8212; 355&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 153&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 43.1<br \/>\n\t&#8212;<br \/>\n\tCREATE PROCEDURE sp_SQLskillsMLChangedData (<br \/>\n\t&nbsp;&nbsp; @dbName VARCHAR (128))<br \/>\n\tAS<br \/>\n\tBEGIN<br \/>\n\t&nbsp;&nbsp; SET NOCOUNT ON;\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; &#8212; Create the temp table<br \/>\n\t&nbsp;&nbsp; &#8212;<br \/>\n\t&nbsp;&nbsp; IF EXISTS (SELECT * FROM msdb.sys.objects WHERE NAME = &#39;SQLskillsDBCCPage&#39;)<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DROP TABLE msdb.dbo.SQLskillsDBCCPage;\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; CREATE TABLE msdb.dbo.SQLskillsDBCCPage (<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ParentObject] VARCHAR (100),<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Object] VARCHAR (100),<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Field] VARCHAR (100),<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [VALUE] VARCHAR (100));\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; DECLARE @fileID INT;<br \/>\n\t&nbsp;&nbsp; DECLARE @fileSizePages INT;<br \/>\n\t&nbsp;&nbsp; DECLARE @extentID INT;<br \/>\n\t&nbsp;&nbsp; DECLARE @pageID INT;<br \/>\n\t&nbsp;&nbsp; DECLARE @MLTotal INT;<br \/>\n\t&nbsp;&nbsp; DECLARE @sizeTotal INT;<br \/>\n\t&nbsp;&nbsp; DECLARE @total INT;<br \/>\n\t&nbsp;&nbsp; DECLARE @dbccPageString VARCHAR (200);\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; SELECT @MLTotal = 0;<br \/>\n\t&nbsp;&nbsp; SELECT @sizeTotal = 0;\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; &#8212; Setup a cursor for all online data files in the database<br \/>\n\t&nbsp;&nbsp; &#8212;<br \/>\n\t&nbsp;&nbsp; DECLARE files CURSOR FOR<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT [file_id], [size] FROM master.sys.master_files<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE [type_desc] = &#39;ROWS&#39;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND [state_desc] = &#39;ONLINE&#39;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND [database_id] = DB_ID (@dbName);\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; OPEN files;\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; FETCH NEXT FROM files INTO @fileID, @fileSizePages;\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; WHILE @@FETCH_STATUS = 0<br \/>\n\t&nbsp;&nbsp; BEGIN<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT @extentID = 0;\n\t<\/p>\n<p>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; The size returned from master.sys.master_files is in<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; pages &#8211; we need to convert to extents<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT @sizeTotal = @sizeTotal + @fileSizePages \/ 8;\n\t<\/p>\n<p>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHILE (@extentID &lt; @fileSizePages)<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BEGIN<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; There may be an issue with the ML map page position<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; on the four extents where PFS pages and GAM pages live<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; (at page IDs 516855552, 1033711104, 1550566656, 2067422208)<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; but I think we&#39;ll be ok.<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; PFS pages are every 8088 pages (page 1, 8088, 16176, etc)<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; GAM extents are every 511232 pages<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT @pageID = @extentID + 7;\n\t<\/p>\n<p>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; Build the dynamic SQL<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT @dbccPageString = &#39;DBCC PAGE (&#39;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + @dbName + &#39;, &#39;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + CAST (@fileID AS VARCHAR) + &#39;, &#39;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + CAST (@pageID AS VARCHAR) + &#39;, 3) WITH TABLERESULTS, NO_INFOMSGS&#39;;\n\t<\/p>\n<p>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; Empty out the temp table and insert into it again<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DELETE FROM msdb.dbo.SQLskillsDBCCPage;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INSERT INTO msdb.dbo.SQLskillsDBCCPage EXEC (@dbccPageString);\n\t<\/p>\n<p>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; Aggregate all the changed extents using the function<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT @total = SUM ([msdb].[dbo].[SQLskillsConvertToExtents] ([Field]))<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM msdb.dbo.SQLskillsDBCCPage<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE [VALUE] = &#39;    MIN_LOGGED&#39;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND [ParentObject] LIKE &#39;ML_MAP%&#39;;\n\t<\/p>\n<p>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET @MLTotal = @MLTotal + @total;\n\t<\/p>\n<p>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; Move to the next GAM extent<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET @extentID = @extentID + 511232;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; END\n\t<\/p>\n<p>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FETCH NEXT FROM files INTO @fileID, @fileSizePages;<br \/>\n\t&nbsp;&nbsp; END;\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; &#8212; Clean up<br \/>\n\t&nbsp;&nbsp; &#8212;<br \/>\n\t&nbsp;&nbsp; DROP TABLE msdb.dbo.SQLskillsDBCCPage;<br \/>\n\t&nbsp;&nbsp; CLOSE files;<br \/>\n\t&nbsp;&nbsp; DEALLOCATE files;\n\t<\/p>\n<p>\n\t&nbsp;&nbsp; &#8212; Output the results<br \/>\n\t&nbsp;&nbsp; &#8212;<br \/>\n\t&nbsp;&nbsp; SELECT<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @sizeTotal AS [Total Extents],<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @MLTotal AS [Changed Extents],<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ROUND (<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (CONVERT (FLOAT, @MLTotal) \/<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CONVERT (FLOAT, @sizeTotal)) * 100, 2) AS [Percentage Changed];<br \/>\n\tEND;<br \/>\n\tGO\n\t<\/p>\n<p>\n\t&#8212; Mark the SP as a system object<br \/>\n\t&#8212;<br \/>\n\tEXEC sys.sp_MS_marksystemobject sp_SQLskillsMLChangedData;<br \/>\n\tGO\n\t<\/p>\n<p>\n\t&#8212; Test to make sure everything was setup correctly<br \/>\n\t&#8212;<br \/>\n\tEXEC sp_SQLskillsMLChangedData &#39;msdb&#39;;<br \/>\n\tGO\n\t<\/p>\n<\/blockquote>\n<p><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>About a year ago, I blogged a cool script that would work out how much of a database has changed since the last full backup &#8211; i.e. how big will the next differential backup be. You can find that script at New script: How much of the database has changed since the last full backup?. [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,31,38,98],"tags":[],"class_list":["post-853","post","type-post","status-publish","format-standard","hentry","category-backuprestore","category-database-maintenance","category-example-scripts","category-transaction-log"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>New script: how much data will the next log backup include? - Paul S. Randal<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"New script: how much data will the next log backup include? - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"About a year ago, I blogged a cool script that would work out how much of a database has changed since the last full backup &#8211; i.e. how big will the next differential backup be. You can find that script at New script: How much of the database has changed since the last full backup?. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2009-05-24T14:32:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-08-31T23:06:23+00:00\" \/>\n<meta name=\"author\" content=\"Paul Randal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Paul Randal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/\",\"name\":\"New script: how much data will the next log backup include? - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2009-05-24T14:32:00+00:00\",\"dateModified\":\"2018-08-31T23:06:23+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"New script: how much data will the next log backup include?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\",\"name\":\"Paul S. Randal\",\"description\":\"In Recovery...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\",\"name\":\"Paul Randal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"caption\":\"Paul Randal\"},\"sameAs\":[\"http:\/\/3.209.169.194\/blogs\/paul\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"New script: how much data will the next log backup include? - Paul S. Randal","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/","og_locale":"en_US","og_type":"article","og_title":"New script: how much data will the next log backup include? - Paul S. Randal","og_description":"About a year ago, I blogged a cool script that would work out how much of a database has changed since the last full backup &#8211; i.e. how big will the next differential backup be. You can find that script at New script: How much of the database has changed since the last full backup?. [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/","og_site_name":"Paul S. Randal","article_published_time":"2009-05-24T14:32:00+00:00","article_modified_time":"2018-08-31T23:06:23+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/","name":"New script: how much data will the next log backup include? - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2009-05-24T14:32:00+00:00","dateModified":"2018-08-31T23:06:23+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/new-script-how-much-data-will-the-next-log-backup-include\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"New script: how much data will the next log backup include?"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/","name":"Paul S. Randal","description":"In Recovery...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce","name":"Paul Randal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","caption":"Paul Randal"},"sameAs":["http:\/\/3.209.169.194\/blogs\/paul"],"url":"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/comments?post=853"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/853\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}