---
title: "Merging Attachments in the Database"
canonical: "https://docs.perspectium.com/space/custom/2490379/Merging%20Attachments%20in%20the%20Database"
format: markdown
---
Feature available in Helium 6.0.1 release Attachments are stored in ServiceNow in two separate tables,  sys_attachment  and  sys_attachment_doc . The  sys_attachment  record holds information about the attachment (such as the file name and file size), while the  sys_attachment_doc  table contains the actual byte data of the attachment separated into different chunks so as to not have one record take up too much space in a table row. Thus, sending attachment(s) to your database with the DataSync Agent will store the attachment(s) in the two tables just as they are stored in ServiceNow.  For   edge encrypted   attachments, ServiceNow will encrypt the attachment byte data when the attachment is in one piece and then split up the encrypted content into chunks for saving in the  sys_attachment_doc  table. As a result, this content is not usable since each  sys_attachment_doc  record is only one portion of the encrypted content.  By including a  SysAttachmentHandler  in the  DataSync Agent  configuration , the Agent will query the  sys_attachment  and  sys_attachment_doc  tables and merge the attachment records back together into one record . The records are removed from these two tables and the merged attachment records can then be stored in whole in the database (in a new table called  attachments ) or shared out as messages back to the Integration Mesh.   NOTE :  Storing the attachments as complete records in the database will lead to large table rows. Ensure your database has the necessary storage space to save these large records. When saving attachments into the database, an  attachments  table gets created to store the fully built attachments and has the following structure: Column SQL Data Type* Description sys_id varchar(40) sys_id of the sys_attachment record table_name varchar(128) Name of the table that the file is attached to file_name varchar(128) Name of the file content_type varchar(128) Type of file table_sys_id varchar(32) sys_id of the record the file is attached to position bigint Will have a value of  0  to represent a full attachment starting at the beginning (0) position attachment varchar(max) Attachment's complete byte data. This column's data can be used to get the whole attachment as one viewable file. *Data types shown are for MySQL/SQL Server. Other databases will create columns in their equivalent data types (for example, Oracle will create the position field as a number field data type, its equivalent of bigint). Prerequisites  First, you will need to set up one of the Perspectium  DataSync Agents .   You should also  stop running your DataSync Agent  before making any Agent configuration changes. Procedure To set up merging of attachments, follow these steps: