Skip to content

Commit 5753521

Browse files
committed
Compare environment settings
1 parent 1c25f3c commit 5753521

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
declare @source xml = '<place source XML result here>';
2+
declare @target xml = '<place target xml result here>';
3+
4+
with
5+
src as(
6+
select property = x.v.value('name[1]', 'nvarchar(300)'),
7+
value = x.v.value('value[1]', 'nvarchar(300)')
8+
from @source.nodes('//row') x(v)
9+
UNION ALL
10+
select property = 'DB-CONFIG:'+y.v.value('local-name(.)', 'nvarchar(300)'),
11+
value = y.v.value('.[1]', 'nvarchar(300)')
12+
from @source.nodes('//db') x(v)
13+
cross apply x.v.nodes('*') y(v)
14+
UNION ALL
15+
select property = 'TEMPDB:'+y.v.value('local-name(.)', 'nvarchar(300)'),
16+
value = y.v.value('.[1]', 'nvarchar(300)')
17+
from @source.nodes('//tempdb') x(v)
18+
cross apply x.v.nodes('*') y(v)
19+
),
20+
tgt as(
21+
select property = x.v.value('name[1]', 'nvarchar(300)'),
22+
value = x.v.value('value[1]', 'nvarchar(300)')
23+
from @target.nodes('//row') x(v)
24+
UNION ALL
25+
select property = 'DB-CONFIG:'+y.v.value('local-name(.)', 'nvarchar(300)'),
26+
value = y.v.value('.[1]', 'nvarchar(300)')
27+
from @target.nodes('//db') x(v)
28+
cross apply x.v.nodes('*') y(v)
29+
UNION ALL
30+
select property = 'TEMPDB:'+y.v.value('local-name(.)', 'nvarchar(300)'),
31+
value = y.v.value('.[1]', 'nvarchar(300)')
32+
from @target.nodes('//tempdb') x(v)
33+
cross apply x.v.nodes('*') y(v)
34+
)
35+
select property = isnull(src.property, tgt.property),
36+
source = src.value, target = tgt.value
37+
from src full outer join tgt on src.property = tgt.property
38+
where (src.value <> tgt.value
39+
or src.value is null and tgt.value is not null
40+
or src.value is not null and tgt.value is null)
41+
order by isnull(src.property, tgt.property)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
declare @db_name sysname = 'master'
2+
3+
begin
4+
declare @result NVARCHAR(MAX);
5+
set @result = (select compatibility_level, snapshot_isolation_state_desc, is_read_committed_snapshot_on,
6+
is_auto_update_stats_on, is_auto_update_stats_async_on, delayed_durability_desc,
7+
is_encrypted, is_auto_create_stats_incremental_on, is_arithabort_on, is_ansi_warnings_on, is_parameterization_forced
8+
from sys.databases
9+
where name = @db_name
10+
for xml raw('db'), elements);
11+
set @result += (select compatibility_level, snapshot_isolation_state_desc, is_read_committed_snapshot_on,
12+
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
14+
from sys.databases
15+
where name = 'tempdb'
16+
for xml raw('tempdb'), elements);
17+
set @result += (
18+
select name = CONCAT('DB-CONFIG:',name), value
19+
from sys.database_scoped_configurations
20+
for xml raw, elements );
21+
declare @tf table (TraceFlag smallint, status bit,global bit, session bit)
22+
insert into @tf execute('DBCC TRACESTATUS(-1)');
23+
set @result += (
24+
select name=CONCAT('TF:',TraceFlag), value=status from @tf
25+
where global=1 and session=0
26+
for xml raw, elements
27+
);
28+
set @result += (
29+
select name = CONCAT('CONFIG:',name), value from sys.configurations
30+
where name in ('cost threshold for parallelism','cursor threshold','fill factor (%)'
31+
,'index create memory (KB)','lightweight pooling'
32+
,'locks','max degree of parallelism','max full-text crawl range','max text repl size (B)'
33+
,'max worker threads','min memory per query (KB)','nested triggers'
34+
,'network packet size (B)','optimize for ad hoc workloads'
35+
,'priority boost','query governor cost limit','query wait (s)','recovery interval (min)'
36+
,'set working set size','user connections')
37+
for xml raw, elements
38+
);
39+
select cast(@result as xml);
40+
end;
41+

0 commit comments

Comments
 (0)