# DataTransfer.AddJoin(Integer, Integer) Method
> Version: _Available or changed with runtime version 10.0._
Adds a field pair to be used to create a join condition which determines which rows to transfer, optional for same table transfers.
## Syntax
```al
 DataTransfer.AddJoin(SourceField: Integer, DestinationField: Integer)
```
## Parameters
DataTransfer
Type: datatransfer-data-type
An instance of the datatransfer-data-type data type.
SourceField
Type: ../integer/integer-data-type
The source table field.
DestinationField
Type: ../integer/integer-data-type
The destination table field.
## Remarks
The DataTransfer object can only be used in upgrade code and it will throw an runtime error if used outside of upgrade codeunits.
Use this method to create a join condition between tables when copying fields from one table to the other. See Transferring Data Bewteen Tables<../../devenv-data-transfer>.
This method isn't needed when copying within the same table.
## Example
In this example, you have two tables, Source and Destination. You're planning on obsoleting field S3 in the Source table. But before you do, you want to copy some values of S3 into the field D3 of the Destination table. Specifically, you only want to copy field S3 in rows where field S2 is equal to A.
```al
local procedure CopyFields()
var
    dt: DataTransfer;
    dest: Record Destination;
    src: Record Source;
begin
    dt.SetTables(Database::Source, Database::Destination);
    dt.AddFieldValue(src.FieldNo("S3"), dest.FieldNo("D3"));
    dt.AddSourceFilter(src.FieldNo("S2"), '=%1', 'A');
    dt.AddJoin(src.FieldNo("PK"), dest.FieldNo("PK"));
    dt.CopyFields();
end;
```
## Related information
datatransfer-data-type
Getting Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/datatransfer/datatransfer-addjoin-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/datatransfer/datatransfer-addjoin-method/
