{"title":"DataTransfer.SetTables(Integer, Integer) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/datatransfer/datatransfer-settables-method/","by":"JOP-AL","license":"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-settables-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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/datatransfer/datatransfer-settables-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Sets the source and destination tables for the data transfer.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"DataTransfer.SetTables(Integer, Integer) Method","slug":"datatransfersettablesinteger-integer-method","at":0,"chars":1681},{"level":2,"title":"Syntax","slug":"syntax","at":173,"chars":93},{"level":2,"title":"Parameters","slug":"parameters","at":266,"chars":283},{"level":2,"title":"Remarks","slug":"remarks","at":549,"chars":304},{"level":2,"title":"Example","slug":"example","at":853,"chars":684},{"level":2,"title":"Related information","slug":"related-information","at":1537,"chars":144}],"text":"# DataTransfer.SetTables(Integer, Integer) Method\n> Version: _Available or changed with runtime version 10.0._\nSets the source and destination tables for the data transfer.\n## Syntax\n```al\n DataTransfer.SetTables(SourceTable: Integer, DestinationTable: Integer)\n```\n## Parameters\nDataTransfer\nType: datatransfer-data-type\nAn instance of the datatransfer-data-type data type.\nSourceTable\nType: ../integer/integer-data-type\nThe source table for the transfer.\nDestinationTable\nType: ../integer/integer-data-type\nThe destination table for the transfer.\n## Remarks\nThe DataTransfer object can only be used in upgrade code and it will throw an runtime error if used outside of upgrade codeunits.\nUse this method when copying data in rows or fields of table to rows or fields of another table. See Transferring Data Between Tables<../../devenv-data-transfer>.\n## Example\nIn this code example, you copy the PK and S3 fields in the Source table for all rows where S2 equals A and add them as new rows in the Destination table. You use AddConstantValue method to give the field D2 the value X in the inserted rows.\n```al\nlocal procedure CopyRows()\nvar\n    dt: DataTransfer;\n    src: Record Source;\n    dest : Record Destination;\nbegin\n    dt.SetTables(Database::Source, Database::Destination);\n    dt.AddFieldValue(src.FieldNo(\"PK\"), dest.FieldNo(\"PK\"));\n    dt.AddFieldValue(src.FieldNo(\"S3\"), dest.FieldNo(\"D3\"));\n    dt.AddConstantValue('X', dest.FieldNo(D2));\n    dt.AddSourceFilter(src.FieldNo(\"S2\"), '=%1', 'A');\n    dt.CopyRows();\nend;\n```\n## Related information\ndatatransfer-data-type\nGetting Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}