---
title: "Importing images and files into Business Central using DataMigrate Pro"
id: "994238"
type: "post"
slug: "import-von-bildern-und-dateien-in-business-central-mittels-datamigrate-pro"
published_at: "2025-09-12T11:52:15+00:00"
modified_at: "2026-03-05T08:24:33+00:00"
url: "https://ioi.gmbh/2025/09/12/import-von-bildern-und-dateien-in-business-central-mittels-datamigrate-pro/?lang=en"
markdown_url: "https://ioi.gmbh/2025/09/12/import-von-bildern-und-dateien-in-business-central-mittels-datamigrate-pro.md?lang=en"
excerpt: "The parameter -t putdata also enables the automatic uploading of files to a Media or Mediaset field of…"
taxonomy_category:
  - "DataMigrate Pro"
  - "Support &amp; Documentation"
---

# Importing images and files into Business Central using DataMigrate Pro

[https://www.facebook.com/sharer.php?text=Importing%20images%20and%20files%20into%20Business%20Central%20using%20DataMigrate%20Pro&u=https://ioi.gmbh/2025/09/12/import-von-bildern-und-dateien-in-business-central-mittels-datamigrate-pro/?lang=en](https://www.facebook.com/sharer.php?text=Importing%20images%20and%20files%20into%20Business%20Central%20using%20DataMigrate%20Pro&u=https://ioi.gmbh/2025/09/12/import-von-bildern-und-dateien-in-business-central-mittels-datamigrate-pro/?lang=en)
[https://twitter.com/share?t=Importing%20images%20and%20files%20into%20Business%20Central%20using%20DataMigrate%20Pro&url=https://ioi.gmbh/2025/09/12/import-von-bildern-und-dateien-in-business-central-mittels-datamigrate-pro/?lang=en](https://twitter.com/share?t=Importing%20images%20and%20files%20into%20Business%20Central%20using%20DataMigrate%20Pro&url=https://ioi.gmbh/2025/09/12/import-von-bildern-und-dateien-in-business-central-mittels-datamigrate-pro/?lang=en)
[http://www.reddit.com/submit?url=https://ioi.gmbh/2025/09/12/import-von-bildern-und-dateien-in-business-central-mittels-datamigrate-pro/?lang=en](http://www.reddit.com/submit?url=https://ioi.gmbh/2025/09/12/import-von-bildern-und-dateien-in-business-central-mittels-datamigrate-pro/?lang=en)
[https://ioi.gmbh/2025/09/12/import-von-bildern-und-dateien-in-business-central-mittels-datamigrate-pro/?lang=en](https://ioi.gmbh/2025/09/12/import-von-bildern-und-dateien-in-business-central-mittels-datamigrate-pro/?lang=en)

The parameter `-t putdata` also enables the automatic uploading of files to a **Media** or **Mediaset field** of a specific table in Business Central. The uploaded files are saved in **Tenant Media** and referenced with a GUID. This GUID is then entered in the corresponding **media** or **media set field** of the target table.

#### **Command syntax**

```
DataMigratePro -t putdata -s <TableNo> -i "<SQL command>" --automapping <TableNo>
```

```
DataMigratePro -t putdata -s <TableNo> -i "<SQL-Befehl>" --automapping <Tabellennummer>
```

or with a manual mapping file:

```
DataMigratePro -t putdata -s <TableNo> -i "<SQL command>" -m <Path to the mapping file>
```

```
DataMigratePro -t putdata -s <TableNo> -i "<SQL-Befehl>" -m <Pfad zur Mapping-Datei>
```

#### **Parameter description**

- `-s <TableNo>` Specifies the target table in Business Central into which the files are imported.
- `-i "<SQL-Befehl>"` Defines the SQL command that provides the required information for the file transfer.
- `--automapping <Tabellennummer>` Automatically creates a mapping for the table and field assignment.
- `-m <Pfad zur Mapping-Datei>` Specifies a manual mapping file if `--automapping` is not used.

---

#### **Functionality**

1. **Execute SQL query** The SQL command transferred via `-i` provides the required information for the file transfer. The following **three or four columns** must be returned for the relevant **Media** or **Mediaset field** in the Business Central target table:
  - `<Feldname>.Description` → Description of the document (e.g. file name)
  - `<Feldname>.MimeType` → MIME type of the file (e.g. `image/jpeg`)
  - **Depending on the source:**
    - `<Feldname>.FilePath` → File path (if the file comes from the file system)
    - `<Feldname>.Content` → File content as `BLOB` (if the file originates from a database)

  - In addition, the SQL command **must** return all primary key fields of the target table in order to assign the file to the correct data record.

2. **Upload files**
  - If `FilePath` is used, the file is loaded from the specified path.
  - If `Content` is used, the file is transferred directly from the SQL query as `BLOB`.
  - The file is saved as a **blob in Tenant Media** and receives a **GUID**.

3. **Link to the Business Central table**
  - The generated GUID is saved in the corresponding **Media** or **Mediaset field**.
  - If it is a **media set**, the new medium is added to the **tenant media set**.

---

#### Case 1: Upload files from the file system to the `[Document Attachment]` table

**Preparatory work**

```
CREATE TABLE [dbo].[ContractDocuments](
  [Contract Code] [nvarchar](20) NOT NULL,
  [FileName] [nvarchar](255) NOT NULL,
  [Extension] [nvarchar](10) NOT NULL,
  [Path to File] [nvarchar](512) NOT NULL,
  CONSTRAINT  [PK_ContractDocuments]  PRIMARY KEY CLUSTERED  
(
  [Contract Code] ASC,
  [FileName] ASC
)
) ON [PRIMARY]
GO
INSERT [dbo].[ContractDocuments] ([Contract Code], [FileName], [Extension], [Path to File])  
VALUES  
  (N'CONTRACT001', N'Arbeitsvertrag_Befristet.pdf', N'pdf', N'C:\Mustervertraege\Arbeitsvertrag_Befristet.pdf')
,(N'CONTRACT002', N'Arbeitsvertrag_Unbefristet.pdf', N'pdf', N'C:\Mustervertraege\Arbeitsvertrag_Unbefristet.pdf')
,(N'CONTRACT003', N'Ausbildungsvertrag.pdf', N'pdf', N'C:\Mustervertraege\Ausbildungsvertrag.pdf')
,(N'CONTRACT004', N'Kulturvertrag.pdf', N'pdf', N'C:\Mustervertraege\Kulturvertrag.pdf')
,(N'CONTRACT005', N'Bauvertrag.pdf', N'pdf', N'C:\Mustervertraege\Bauvertrag.pdf')
GO
```

```
CREATE TABLE [dbo].[ContractDocuments](
	[Contract Code] [nvarchar](20) NOT NULL,
	[FileName] [nvarchar](255) NOT NULL,
	[Extension] [nvarchar](10) NOT NULL,
	[Path to File] [nvarchar](512) NOT NULL,
 CONSTRAINT [PK_ContractDocuments] PRIMARY KEY CLUSTERED 
(
	[Contract Code] ASC,
	[FileName] ASC
)
) ON [PRIMARY]
GO
INSERT [dbo].[ContractDocuments] ([Contract Code], [FileName], [Extension], [Path to File]) 
VALUES 
 (N'CONTRACT001', N'Arbeitsvertrag_Befristet.pdf', N'pdf', N'C:\Mustervertraege\Arbeitsvertrag_Befristet.pdf')
,(N'CONTRACT002', N'Arbeitsvertrag_Unbefristet.pdf', N'pdf', N'C:\Mustervertraege\Arbeitsvertrag_Unbefristet.pdf')
,(N'CONTRACT003', N'Ausbildungsvertrag.pdf', N'pdf', N'C:\Mustervertraege\Ausbildungsvertrag.pdf')
,(N'CONTRACT004', N'Kulturvertrag.pdf', N'pdf', N'C:\Mustervertraege\Kulturvertrag.pdf')
,(N'CONTRACT005', N'Bauvertrag.pdf', N'pdf', N'C:\Mustervertraege\Bauvertrag.pdf')
GO
```

Preparation must also be carried out in the mapping configuration or a manual mapping must be created. Here is the first variant, in which the source configuration is based on the SQL query and cannot be derived from the structure of NAV and must therefore be entered manually.

The SQL query returns the **primary key** (`[ID],[Table ID],[No_]`) and the **file information** for the **media field**`[Document Reference ID]`:

```
SELECT ROW_NUMBER() OVER(ORDER BY [Contract Code]) [ID]
, 8052 [Table ID] -- Accounts Receivable Contracts
, [Contract Code] [No_]
, 21 [Document Type] -- Service Contract
, 0 [Line No_]
, GETDATE() [Attached Date]
, [FileName] [File Name]
, [Extension] [File Extension]
, [FileName] [Document Reference ID.Description]
, CASE WHEN [Extension] = 'jpg' THEN 'image/jpeg' WHEN [Extension] = 'png' THEN 'image/png' ELSE 'application/octet-stream' END AS [Document Reference ID.MimeType]
, [Path to File] [Document Reference ID.FilePath]
 FROM [dbo].[ContractDocuments]
```

```
SELECT ROW_NUMBER() OVER(ORDER BY [Contract Code]) [ID]
     , 8052 [Table ID] -- Debitorenverträge
	 , [Contract Code] [No_]
	 , 21 [Document Type] -- Service Contract
	 , 0 [Line No_]
	 , GETDATE() [Attached Date]
	 , [FileName] [File Name]
     , [Extension] [File Extension]
     , [FileName] [Document Reference ID.Description]
	 , CASE WHEN [Extension] = 'jpg' THEN 'image/jpeg' WHEN [Extension] = 'png' THEN 'image/png' ELSE 'application/octet-stream' END AS [Document Reference ID.MimeType]
     , [Path to File] [Document Reference ID.FilePath]
  FROM [dbo].[ContractDocuments]
```

**Command for execution:**

```
DataMigratePro -t putdata -s 1173 -i "SELECT ROW_NUMBER() OVER(ORDER BY [Contract Code]) [ID], 8052 [Table ID], [Contract Code] [No_], 21 [Document Type] -- Service Contract, 0 [Line No_], GETDATE() [Attached Date], [FileName] [File Name], [Extension] [File Extension], [FileName] [Document Reference ID.Description], CASE WHEN [Extension] = 'jpg' THEN 'image/jpeg' WHEN [Extension] = 'png' THEN 'image/png' ELSE 'application/octet-stream' END AS [Document Reference ID.MimeType], [Path to File] [Document Reference ID.FilePath] FROM [dbo].[ContractDocuments]" --automapping 1173
```

```
DataMigratePro -t putdata -s 1173 -i "SELECT ROW_NUMBER() OVER(ORDER BY [Contract Code]) [ID], 8052 [Table ID], [Contract Code] [No_], 21 [Document Type] -- Service Contract, 0 [Line No_], GETDATE() [Attached Date], [FileName] [File Name], [Extension] [File Extension], [FileName] [Document Reference ID.Description], CASE WHEN [Extension] = 'jpg' THEN 'image/jpeg' WHEN [Extension] = 'png' THEN 'image/png' ELSE 'application/octet-stream' END AS [Document Reference ID.MimeType], [Path to File] [Document Reference ID.FilePath] FROM [dbo].[ContractDocuments]" --automapping 1173
```

---

#### **Case 2: Uploading files from a BLOB field in the database**

If the files are stored in an SQL database as `BLOB`, `.Content` must be used instead:

```
SELECT 
 [Contract Code] AS [Code], 
 [FileName] AS [Documents.Description], 
 [MimeType] AS [Documents.MimeType], 
 [FileContent] AS [Documents.Content] 
FROM [Some Table with Document Information]
```

```
SELECT 
    [Contract Code] AS [Code], 
    [FileName] AS [Documents.Description], 
    [MimeType] AS [Documents.MimeType], 
    [FileContent] AS [Documents.Content] 
FROM [Some Table with Document Information]
```

**Command for execution:**

```
DataMigratePro -t putdata -s 50000 -i "SELECT ..." --automapping 50000
```

```
DataMigratePro -t putdata -s 50000 -i "SELECT ..." --automapping 50000
```

---

#### **Prerequisites**

- The target table in Business Central **must contain a Media or Mediaset field**.
- If `FilePath` is used, **the files must be physically available on the server**.
- If `Content` is used, **the file must already** exist **as a BLOB in the SQL database**.
- The Business Central instance must be configured for the use of **media/mediaset fields**.

#### **Supported file formats**

- **Pictures**: `jpg`, `png`, `gif`, `bmp`, `tiff`
- **Documents**: `pdf`, `txt`, `docx`
