Skip to content

Commit 6178cc2

Browse files
committed
Adding tempdb #files and refactoring
1 parent 5753521 commit 6178cc2

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

samples/manage/azure-sql-db-managed-instance/compare-environment-settings/compare-properties.sql

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare @source xml = '<place source XML result here>';
2-
declare @target xml = '<place target xml result here>';
2+
declare @target xml = '<place target XML result here>';
33

44
with
55
src as(
@@ -31,11 +31,18 @@ select property = 'TEMPDB:'+y.v.value('local-name(.)', 'nvarchar(300)'),
3131
value = y.v.value('.[1]', 'nvarchar(300)')
3232
from @target.nodes('//tempdb') x(v)
3333
cross apply x.v.nodes('*') y(v)
34-
)
34+
),
35+
diff as (
3536
select property = isnull(src.property, tgt.property),
36-
source = src.value, target = tgt.value
37+
source = src.value, target = tgt.value,
38+
is_missing = (case when src.value is null or tgt.value is null then 1 else 0 end)
3739
from src full outer join tgt on src.property = tgt.property
3840
where (src.value <> tgt.value
3941
or src.value is null and tgt.value is not null
4042
or src.value is not null and tgt.value is null)
41-
order by isnull(src.property, tgt.property)
43+
)
44+
select *
45+
from diff
46+
where is_missing = 0 -- comment-out this line to compare missing properties.
47+
order by property
48+

samples/manage/azure-sql-db-managed-instance/compare-environment-settings/get-properties.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ where name = @db_name
1010
for xml raw('db'), elements);
1111
set @result += (select compatibility_level, snapshot_isolation_state_desc, is_read_committed_snapshot_on,
1212
is_auto_update_stats_on, is_auto_update_stats_async_on, delayed_durability_desc,
13-
is_encrypted, is_auto_create_stats_incremental_on, is_arithabort_on, is_ansi_warnings_on, is_parameterization_forced
13+
is_encrypted, is_auto_create_stats_incremental_on, is_arithabort_on, is_ansi_warnings_on, is_parameterization_forced,
14+
number_of_files = (select count(*) from master.sys.master_files where database_id = db_id('tempdb'))
1415
from sys.databases
1516
where name = 'tempdb'
1617
for xml raw('tempdb'), elements);

0 commit comments

Comments
 (0)