Friday, June 11, 2010

Finding CRM 4.0 Entities with Attachments by Querying annotationBase Table

I needed to find all of the inactive records for an entity that had documents attached:

 

SELECT COUNT(*)
FROM   new_myEntityBase t
       JOIN annotationBase ab
         ON t.myentityid = ab.objectid
WHERE  statecode = 1