Skip to content

Instantly share code, notes, and snippets.

@jasonamyers
Created March 27, 2012 01:15
Show Gist options
  • Save jasonamyers/2211425 to your computer and use it in GitHub Desktop.
Save jasonamyers/2211425 to your computer and use it in GitHub Desktop.
MS CRM: Select Non-email Attachments
SELECT
DocumentBody,
ObjectId,
FileName,
CONVERT(varchar(255), ObjectId) + '_' + CONVERT(varchar(255), Filename) AS SaveAsFileName
FROM
FilteredAnnotation
WHERE
IsDocument = 1 AND
(objecttypecode = 1 or -- Account Note Attachments
objecttypecode = 2 or -- Contact Note Attachments
objecttypecode = 3 or -- Opportunity Note Attachments
objecttypecode = 4 or -- Lead Note Attachments
objecttypecode = 4212 or -- All Task Note Attachments
objecttypecode = 4201 or -- All Appointment Note Attachments
objecttypecode = 4210) -- All Phone Call Note Attachments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment