{"title":"Database.CopyCompany(Text, Text) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/database/database-copycompany-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/database/database-copycompany-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/database/database-copycompany-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":"Creates a new company and copies all data from an existing company in the same database.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Database.CopyCompany(Text, Text) Method","slug":"databasecopycompanytext-text-method","at":0,"chars":2097},{"level":2,"title":"Syntax","slug":"syntax","at":191,"chars":167},{"level":2,"title":"Parameters","slug":"parameters","at":358,"chars":500},{"level":2,"title":"Return Value","slug":"return-value","at":858,"chars":238},{"level":2,"title":"Remarks","slug":"remarks","at":1096,"chars":432},{"level":2,"title":"Example","slug":"example","at":1528,"chars":433},{"level":2,"title":"Related information","slug":"related-information","at":1961,"chars":136}],"text":"# Database.CopyCompany(Text, Text) Method\n> Version: _Available or changed with runtime version 1.0._\nCreates a new company and copies all data from an existing company in the same database.\n## Syntax\n```al\n[Ok := ]  Database.CopyCompany(SourceName: Text, DestinationName: Text)\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nSourceName\nType: ../text/text-data-type\nThe name of the company that you want to copy data from.\nDestinationName\nType: ../text/text-data-type\nThe name of the company that you want to create and copy data to. The company name can have a maximum of 30 characters. If the database collation is case-sensitive, you can have one company called COMPANY and another called Company. However, if the database is case-insensitive, you cannot create companies with names that differ only by case.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.\n## Remarks\nLinks and notes on records are not copied to the new company.\nWith versions 17.5 and later, errors in COPYCOMPANY can't be trapped. This change prevents a company from being partially copied when an error occurs and it's followed by a COMMIT(). Any error in COPYCOMPANY ends the execution flow, even with statements like: `IF NOT CopyCompany(.., ..) THEN`. Also, any COMMIT() in triggers or event subscribers is ignored.\n## Example\nThe following example is based on the Copy Company batch job, which is part of the CRONUS. The batch job takes the Company system table as a data item and uses the Name field as the value of the SourceName parameter. The value of the DestinationName parameter is specified in the New Company Name field in the request page, which is represented by the NewCompanyName variable.\n```al\nCopyCompany(Name, NewCompanyName);\n```\n## Related information\ndatabase-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}