mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Merge pull request #562 from JocaPC/master
Adding tempdb #files and refactoring
This commit is contained in:
+11
-4
@@ -1,5 +1,5 @@
|
||||
declare @source xml = '<place source XML result here>';
|
||||
declare @target xml = '<place target xml result here>';
|
||||
declare @target xml = '<place target XML result here>';
|
||||
|
||||
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
|
||||
|
||||
|
||||
+2
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user