Hello,
Since direct upgrades from Windows Server 2012 to 2022 are not supported, you need to first upgrade to Windows Server 2016, then upgrade to Server 2022.
You'll need to purchase licenses for the appropriate version to perform in-place upgrade. And make sure your system meets the requirements for installing Server 2022 before upgrading, please refer to the link for more details:
Perform a Feature Update of Windows Server | Microsoft Learn
However, on the premise that the system meets the requirements, I recommend that you perform a clean installation of Server 2022.
Note: Make a backup of your important data before upgrading.
Have a nice day.
Best Regards,
Hania