If you see the following issue after upgrading to SQL 2019


"Internal error: An expression services limit has been reached. Please look for potentially complex expressions in your query, and try to simplify them."


Set the database to SQL 2017 compatibility mode


ALTER DATABASE [TheOrderExchange] SET COMPATIBILITY_LEVEL = 140


Check the stored procedure runs, then try set it back to 2019 compatibility mode


ALTER DATABASE [TheOrderExchange] SET COMPATIBILITY_LEVEL = 150