mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Merge pull request #561 from JocaPC/master
Compare environment settings
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
declare @source xml = '<place source XML result here>';
|
||||
declare @target xml = '<place target xml result here>';
|
||||
|
||||
with
|
||||
src as(
|
||||
select property = x.v.value('name[1]', 'nvarchar(300)'),
|
||||
value = x.v.value('value[1]', 'nvarchar(300)')
|
||||
from @source.nodes('//row') x(v)
|
||||
UNION ALL
|
||||
select property = 'DB-CONFIG:'+y.v.value('local-name(.)', 'nvarchar(300)'),
|
||||
value = y.v.value('.[1]', 'nvarchar(300)')
|
||||
from @source.nodes('//db') x(v)
|
||||
cross apply x.v.nodes('*') y(v)
|
||||
UNION ALL
|
||||
select property = 'TEMPDB:'+y.v.value('local-name(.)', 'nvarchar(300)'),
|
||||
value = y.v.value('.[1]', 'nvarchar(300)')
|
||||
from @source.nodes('//tempdb') x(v)
|
||||
cross apply x.v.nodes('*') y(v)
|
||||
),
|
||||
tgt as(
|
||||
select property = x.v.value('name[1]', 'nvarchar(300)'),
|
||||
value = x.v.value('value[1]', 'nvarchar(300)')
|
||||
from @target.nodes('//row') x(v)
|
||||
UNION ALL
|
||||
select property = 'DB-CONFIG:'+y.v.value('local-name(.)', 'nvarchar(300)'),
|
||||
value = y.v.value('.[1]', 'nvarchar(300)')
|
||||
from @target.nodes('//db') x(v)
|
||||
cross apply x.v.nodes('*') y(v)
|
||||
UNION ALL
|
||||
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)
|
||||
)
|
||||
select property = isnull(src.property, tgt.property),
|
||||
source = src.value, target = tgt.value
|
||||
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)
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
declare @db_name sysname = 'master'
|
||||
|
||||
begin
|
||||
declare @result NVARCHAR(MAX);
|
||||
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
|
||||
from sys.databases
|
||||
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
|
||||
from sys.databases
|
||||
where name = 'tempdb'
|
||||
for xml raw('tempdb'), elements);
|
||||
set @result += (
|
||||
select name = CONCAT('DB-CONFIG:',name), value
|
||||
from sys.database_scoped_configurations
|
||||
for xml raw, elements );
|
||||
declare @tf table (TraceFlag smallint, status bit,global bit, session bit)
|
||||
insert into @tf execute('DBCC TRACESTATUS(-1)');
|
||||
set @result += (
|
||||
select name=CONCAT('TF:',TraceFlag), value=status from @tf
|
||||
where global=1 and session=0
|
||||
for xml raw, elements
|
||||
);
|
||||
set @result += (
|
||||
select name = CONCAT('CONFIG:',name), value from sys.configurations
|
||||
where name in ('cost threshold for parallelism','cursor threshold','fill factor (%)'
|
||||
,'index create memory (KB)','lightweight pooling'
|
||||
,'locks','max degree of parallelism','max full-text crawl range','max text repl size (B)'
|
||||
,'max worker threads','min memory per query (KB)','nested triggers'
|
||||
,'network packet size (B)','optimize for ad hoc workloads'
|
||||
,'priority boost','query governor cost limit','query wait (s)','recovery interval (min)'
|
||||
,'set working set size','user connections')
|
||||
for xml raw, elements
|
||||
);
|
||||
select cast(@result as xml);
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user