From 6178cc2f62e164c0bd7520200bc6367b872cd7d6 Mon Sep 17 00:00:00 2001 From: Jovan Popovic Date: Tue, 7 May 2019 09:42:39 +0200 Subject: [PATCH] Adding tempdb #files and refactoring --- .../compare-properties.sql | 15 +++++++++++---- .../get-properties.sql | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/samples/manage/azure-sql-db-managed-instance/compare-environment-settings/compare-properties.sql b/samples/manage/azure-sql-db-managed-instance/compare-environment-settings/compare-properties.sql index b9fcbdb5..a0610e9e 100644 --- a/samples/manage/azure-sql-db-managed-instance/compare-environment-settings/compare-properties.sql +++ b/samples/manage/azure-sql-db-managed-instance/compare-environment-settings/compare-properties.sql @@ -1,5 +1,5 @@ declare @source xml = ''; -declare @target xml = ''; +declare @target xml = ''; with src as( @@ -31,11 +31,18 @@ select property = 'TEMPDB:'+y.v.value('local-name(.)', 'nvarchar(300)'), value = y.v.value('.[1]', 'nvarchar(300)') from @target.nodes('//tempdb') x(v) cross apply x.v.nodes('*') y(v) -) +), +diff as ( select property = isnull(src.property, tgt.property), - source = src.value, target = tgt.value + source = src.value, target = tgt.value, + is_missing = (case when src.value is null or tgt.value is null then 1 else 0 end) from src full outer join tgt on src.property = tgt.property where (src.value <> tgt.value or src.value is null and tgt.value is not null or src.value is not null and tgt.value is null) -order by isnull(src.property, tgt.property) +) +select * +from diff +where is_missing = 0 -- comment-out this line to compare missing properties. +order by property + diff --git a/samples/manage/azure-sql-db-managed-instance/compare-environment-settings/get-properties.sql b/samples/manage/azure-sql-db-managed-instance/compare-environment-settings/get-properties.sql index a56ebf1f..ee277816 100644 --- a/samples/manage/azure-sql-db-managed-instance/compare-environment-settings/get-properties.sql +++ b/samples/manage/azure-sql-db-managed-instance/compare-environment-settings/get-properties.sql @@ -10,7 +10,8 @@ where name = @db_name for xml raw('db'), elements); set @result += (select compatibility_level, snapshot_isolation_state_desc, is_read_committed_snapshot_on, is_auto_update_stats_on, is_auto_update_stats_async_on, delayed_durability_desc, - is_encrypted, is_auto_create_stats_incremental_on, is_arithabort_on, is_ansi_warnings_on, is_parameterization_forced + is_encrypted, is_auto_create_stats_incremental_on, is_arithabort_on, is_ansi_warnings_on, is_parameterization_forced, + number_of_files = (select count(*) from master.sys.master_files where database_id = db_id('tempdb')) from sys.databases where name = 'tempdb' for xml raw('tempdb'), elements);