How To

Export SharePoint Documents to a SQL Table in Binary Format

If you want to export documents from a SharePoint Document Library to a SQL Table and store them in their binary format, so then they can be used in other processes, follow the guide below.

Prepare the SQL Table

You need to make sure that your SQL Table has a column ready to hold your document with the data type set to varbinary.

SQL Table Design

Create the Data Sync Project

Now connect to your SharePoint Document Library and add the columns you want to the schema map. Connect to your SQL table on the target side and map the columns to their counterparts in the schema map.

Data Sync Project

You do not map the SQL table Document column in the schema map, this is handled by the next step.

To get the binary data into your SQL table change the connection property Blob Column on the SQL connection to be your Document column. This property will pull in the data to the specified column.

Blob Column Property

Now run the compare and Synchronise the changes.

Final Result

If we look at our SQL table we can see that documents have been added, and are showing as a Byte[] Array.

SQL Table Data

To make sure that this array has data if we run a SQL statement to get the data length of our Document column. The varying lengths show that data is contained within this column as each file contains different data.

Data Length