Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

MDW Data Collector doesn't work, meaning the custom_Snapshot table isn't created? Why? ? ?

$
0
0

I think the issue is with a long query in XML. Please, how to make this work?

Here are the definitions I used:

STEP 1 --- Find Collecter TYPE ID from

SELECT collector_type_uid ,* FROM [msdb].[dbo].[syscollector_collector_types_internal]

STEP 2 -- find the schedule

STEP 3  -- create collection SET using a SP

DECLARE @collectionsetid int 
DECLARE @collectionsetuid uniqueidentifier
EXEC [msdb].[dbo].[sp_syscollector_create_collection_set]
@name=N'Index Fragmentation Usage Report3',
 @collection_mode=1, -- Non-cached mode 
 @description=N'Records fragmentation of indexes over 100 pages AGAIN',
 @days_until_expiration=30, -- 400=A year and a month --number of days
 @schedule_uid='C40E90DE-5ECC-4B89-9DF8-424DD6160A0A',
 @collection_set_id=@collectionsetid OUTPUT,
 @collection_set_uid=@collectionsetuid OUTPUT

STEP 4 --- Create the job definition and QUERY

DECLARE @parameters XML 
Set @parameters=' <ns:TSQLQueryCollector xmlns:ns="DataCollectorType"> 
 <Query> 
 <Value>Select
 db_name([database_id])+''.''+Sch.[Name]+''.''+T.[Name]+''.''+Indexes.[Name] as [IndexName],  S.[FragmentationPercentage] 
FROM (Select 
 [database_id], [object_id], [index_id], 
 Sum(avg_fragmentation_in_percent * 
page_count)/Sum(page_count) as [FragmentationPercentage] 
 FROM sys.dm_db_index_physical_stats( db_id(), NULL, NULL, NULL, 
''DETAILED'') 
 Where index_type_desc IN (''CLUSTERED INDEX'',''NONCLUSTERED INDEX'') 
AND alloc_unit_type_desc=''IN_ROW_DATA'' 
Group by [database_id],[object_id],[index_id] 
) S 
Join Sys.objects T On S.[object_id] = T.[object_id] 
Join Sys.schemas sch On Sch.[schema_id] = T.[schema_id] 
Join Sys.Indexes On Indexes.[Object_id] = S.[Object_Id] And 
Indexes.[Index_id] = S.[Index_id] </Value> 
 <OutputTable>IndexFragmentation</OutputTable> 
 </Query> 
 <Databases UseUserDatabases="true" /> 
</ns:TSQLQueryCollector> ' 

DECLARE @collectionitem INT
EXEC [msdb].[dbo].[sp_syscollector_create_collection_item]
@name=N'Index Fragmentation3',
@parameters=@parameters,
@collection_item_id=@collectionitem OUTPUT,
@collection_set_id=10,
@collector_type_uid='302E93D1-3424-4BE7-AA8E-84813ECF2419'

After the Data Collector is created, and I run it by right clicking it and select "collect and upload now", it isn't creating the custom_snapshot table that it should create?????  PLease what am I doing wrong????



Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>