Hi SVV
When you swap out hardware, Windows sees it as a new machine, so the old activation key won’t carry over unless you still have it handy. Since you’ve lost the code, the only way forward is to recover or replace the license. If your Server 2022 Datacenter license was purchased through Volume Licensing Service Center or Microsoft 365 Admin portal, you can log in there and re‑download the product key. If it was OEM, you’ll need to contact the hardware vendor for a replacement key. Retail purchases can usually be recovered by signing into your Microsoft account and checking your order history.
Once you’ve got the key, just run slmgr /ipk <your-key> followed by slmgr /ato to re‑activate on the new hardware. If activation fails, Microsoft support can help re‑issue or validate the license against the new hardware profile. Best practice is to keep a secure record of your keys in a password manager or license vault so you don’t run into this again.