New SQL Update or SP from Microsoft
If you need help updating and patching your SQL Server, or upgrading to a new version of SQL Server Stedman Solutions can help. With the amount… Read More »New SQL Update or SP from Microsoft
If you need help updating and patching your SQL Server, or upgrading to a new version of SQL Server Stedman Solutions can help. With the amount… Read More »New SQL Update or SP from Microsoft
Today Microsoft released CU #26 for SQL Server 2017. Wow 26 CU’s for a SQL Server product. What is really amazing is that it is… Read More »Cumulative Update #26 for SQL Server 2017
Working on a recent SQL Server merge replication project we needed to update some of the servers in a merge replication scenario without upgrading all… Read More »For merge publications, the version of the Subscriber must not exceed the version of the Publisher
With SQL Server 2017, there was a new compatibility level introduced, level 140 the new SQL Server 2017 Compatibility Level. SQL Server can run in a… Read More »SQL Server 2017 Compatibility Levels
SQL Server 2017 introduces a new column in the sys.dm_db_file_space_usage system table. The column is modified_extent_page_count, which tells how many pages have been modified in your data file since the last full backup.
SELECT * FROM sys.dm_db_file_space_usage;
What is really interesting about this is that with a little math you can calculate the percentage of your data file that has been modified. This would be useful when running differential backups to be able to determine if it would make more sense to run a full backup or a differential backup. Basically when your differential backup gets large enough, based on the number of modified_extent_page_count pages, then it may make sense to do a full backup and reset this counter, and get back to smaller differential backups.
Here is an example
SELECT df.name, df.physical_name, total_page_count, allocated_extent_page_count, modified_extent_page_count, 100.0 * modified_extent_page_count / allocated_extent_page_count as PercentChanged FROM sys.dm_db_file_space_usage fsu INNER JOIN sys.database_files df on df.file_id = fsu.file_id;
Now based on the Percent Changed column we can make some assumptions on the size of the differential backup, and decide if we want to do a differential backup or a full backup.
Read More »Determining how much of your data file has been modified
For more information on cursors, also take a look at the free SQL query training provided by Steve Stedman. Cursors are a feature of SQL Server… Read More »T-SQL: A Simple Example Using a Cursor