When migrating data from Dynamics CRM, there might be a need to determine which specific objects have Activities such as "Tasks" associated with them. This is especially important in the context of data cleansing because one might not want to migrate data that has not had any activity(tasks) against it in a while.
Since records typically have a lot of historical activity associated with them, during the data migration discovery process we often have to ask the question: If there are no tasks associated with this record, should we even migrate it?
In order to quantify the Activity associated with a specific object type, the following query can be used:select PhysicalName,rcount from EntityView ev inner join ( select RegardingObjectTypeCode,COUNT(*) as rcount from task group by RegardingObjectTypeCode ) a on ev.ObjectTypeCode=a.RegardingObjectTypeCode
The result of this query is a list of objects and the number of Tasks associated with each object. Armed with this information, one could decide which specific objects are worth migrating over.
The same query can be modified to list data for Meeting records by replacing "task" with "Appointment".