Force SQL Engine to prepare Non-Null plan only for a query that use variable
Following are the three ways that can fix the issue. More approaches are welcome.

Solution 1

Instead of a variable(@DelimitingCharacter), use a temporary table.

CREATE TABLE #VariableHoldingTable (DelimitingCharacter CHAR(1) NOT NULL)
INSERT INTO #VariableHoldingTable
SELECT '&lt;'


--And do a join

  INNER JOIN #VariableHoldingTable V
    ON 1 = 1


Execution Plan: https://www.brentozar.com/pastetheplan/?id=rJpehe5hQ 

Solution 2

CREATE CLUSTERED INDEX CX_DXID on #MultipleDiagnosisDXs(DXID)


Execution Plan: https://www.brentozar.com/pastetheplan/?id=B1nKne9nX

Solution 3

OPTION (RECOMPILE)


Execution Plan: https://www.brentozar.com/pastetheplan/?id=BkRgalqnX