# CodeCop Warning AA0206
The value assigned to a variable must be used.
## Description
The value assigned to a variable must be used, otherwise the variable is not necessary.
## Reason for the rule
Unused variable can be confusing for the reader and can cost performance to the system.
## Bad code example
```al
procedure AddEntities@1(FilterStr@1000 : Text[250])
var
    Vendor@1001 : Record Vendor;
    Count@1002 : Integer;
begin
    Count := 0;
    Vendor.SETFILTER("No.",FilterStr);
    if Vendor.FINDSET() then
    repeat
        "User ID" := USERID();
        "Vendor No." := Vendor."No.";
        If Vendor.Insert() THEN;
    until Vendor.NEXT() = 0;
end;
```
## Good code example
```al
procedure AddEntities@1(FilterStr@1000 : Text[250])
var
    Vendor@1001 : Record Vendor;
begin
    Vendor.SETFILTER("No.",FilterStr);
    if Vendor.FINDSET() then
    repeat
        "User ID" := USERID();
        "Vendor No." := Vendor."No.";
        if Vendor.INSERT() then;
    until Vendor.NEXT() = 0;
end;
```
## Good and bad practices for fixing the rule
Remove the variable or make use of it if not using it was a mistake.
## Related information
CodeCop Analyzer<codecop>
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/codecop-aa0206, 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/codecop-aa0206/
