How to find orphaned records by query on sys_attachment_doc table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2018 10:08 PM
Hi.
Can anyone help me in how to query the orphaned records on attachment document table? I have a requirement to pull all the orphaned records from sys_attachment_doc and clean up them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2018 10:31 PM
That sounds like a very risky operation! Why do you think that you have orpahan records in the attachments table?
It's a very hard task to do because even OOB there's records in the attachment tables that are not associated to a record like an incident or problem or change, or request, etc... instead it could be associated to ts_ or sys_ tables that are for core to the platform.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2018 10:44 PM
HI Berny,
Thank you for your response, the table is sys_attachment_doc table not the sys_attachment table.
Regards,
Bhanu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2018 10:51 PM
Oh! that will be very simple then... you just need to filter for the records which the sys attachment field is empty.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2018 10:35 PM
Go through the below link to get better idea about attachments:
https://snprotips.com/blog/2016/2/25/understanding-and-using-glideattachment
Mark Correct if it solves your issue.
Thanks,
Ravi