SF_DownloadBlobs downloads the binary content of a Salesforce object (Attachment, Knowledge Article, etc.) into a directory on the SQL Server machine. It uses the Salesforce Bulk API and consumes one API call per file downloaded. Make sure you have enough daily API calls in Salesforce prior to running this procedure.

SF_DownloadBlobs takes as input a local SQL Server table that is called the input table.

Input Table

An Input table

  • holds the records IDs of a Salesforce object that contains binary content on Salesforce.

  • must have its name prefix be the name of a valid Salesforce object (e.g., Attachment and Attachment_Test are valid, AttachmentTest is not)

  • must contain the ID field of the Salesforce object, all other fields are ignored.

  • must contain at least one record

  • can be created by SF_Replicate or a table you created manually

SF_DownloadBlobs is a stored procedure that creates files in a local directory with the contents of the binary field(s) of a Salesforce object.

File Name

The file name uses this template: ID_fieldName.File. For example, consider the following file name:


This file belongs to the attachment with ID 00P6000000BR8e1EAD and contains the binary contents of the body field.


 EXEC SF_DownloadBlobs 'table_server','input_table'

where table_server is the name of your linked server and input_table is the name of a valid Input table.

NOTE: The Include Binary Field Values setting must be ‘True’ on the Settings page of the DBAmp Configuration program.


The following example downloads the binary files(s) of the Attachment table into in a local directory on the server called the Blob Directory.

To create an example Input table:

  1. Create the Input table using SF_Replicate. Normally, the Body column of the local Attachment table is null because SF_Replicate does not download the binary content.

    EXEC SF_Replicate ‘SALESFORCE’, ‘Attachment’

  2. Create the Blob Directory:

    a. Run the DBAmp Configuration program.

    b. Navigate to Configuration>Options.

    c. Click Browse to create a Blob Directory

  3. Run SF_DownloadBlobs to create files containing the binary field(s) of the Attachment object in the Blob Directory:

    EXEC SF_DownloadBlobs ‘SALESFORCE’, ‘Attachment’

After execution, the Blob directory contains the individual Attachment files.