Why don't you just follow the Microsoft documentation
starting with checking the upgrade path:
https://learn.microsoft.com/en-us/sql/database-engine/install-windows/supported-version-and-edition-upgrades-2019?view=sql-server-ver16
Followed by documentation on how to migrate from an old to a new version of SQL Server
https://learn.microsoft.com/en-us/sql/sql-server/migrate/guides/sql-server-to-sql-server-upgrade-guide?view=sql-server-ver16
Maybe a different approach might be a migration using PowerShell => dbatools
https://dbatools.io/
They have a migration command for migrating SQL Server very easily and quickly (but still should know what you/the script are doing)
https://docs.dbatools.io/Start-DbaMigration
----------
If this answer helps you - please accept this answer.