# AppSourceCop Error AS0043
The clustered key must not be deleted
## Description
The clustered key must not be deleted.
It's not allowed to rename or remove the clustered key in a table. For more information on table keys, see ../devenv-table-keys.
> NOTE
> This rule validates tables independently of their Accessibility or ObsoleteState, because tables are always used when synchronizing the schema defined in the extension to the database.
## How to fix this diagnostic?
To fix this diagnostic, you must rename the clustered key or add it back so that it matches its definition in your baseline extension.
## Code examples triggering the rule
Version 1.0 of the extension:
```al
table 50100 MyTable
{
    fields
    {
        field(1; MyIntegerField; Integer) { }
        field(2; MyTextField; Text[50]) { }
    }

    keys
    {
        key(PK; MyIntegerField) { }

        key(ClusteredKey; MyTextField)
        {
            Clustered = true;
        }
    }
}
```
### Example 1 - Removing the clustered key
Version 2.0 of the extension:
```al
table 50100 MyTable
{
    fields
    {
        field(1; MyIntegerField; Integer) { }
        field(2; MyTextField; Text[50]) { }
    }

    keys
    {
        key(PK; MyIntegerField) { }
    }
}
```
In version 2.0 of the extension, the clustered key ClusteredKey has been removed. This change is not allowed by the synchronization engine.
### Example 2 - Renaming the clustered key
```al
table 50100 MyTable
{
    fields
    {
        field(1; MyIntegerField; Integer) { }
        field(2; MyTextField; Text[50]) { }
    }

    keys
    {
        key(PK; MyIntegerField) { }

        key(NewClusteredKey; MyTextField)
        {
            Clustered = true;
        }
    }
}
```
In version 2.0 of the extension, the clustered key has been renamed from ClusteredKey to NewClusteredKey. This change is detected as a removal of ClusteredKey and is not allowed by the synchronization engine.
## Related information
AppSourceCop Analyzer<appsourcecop>
Get 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/analyzers/appsourcecop-as0043, 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/analyzers/appsourcecop-as0043/
