Perhaps I'm not explaining clearly enough.
The comparison to the customer ID is hard coded in the WHERE clause. It has nothing to do with the "Customer_ID = " that you initially put in the @WHERE_CLAUSE variable, because you are parsing that out.
You can change the value of @WHERE_CLAUSE to start with "ANYCOLUMN = 0000000008" and the comparison will still be done against the Customer_ID column.
Try altering the second line of your code and see.
-- This works and will always work, but only as a test against the customer_id
DECLARE
@SQL VARCHAR(1000)
, @WHERE_CLAUSE VARCHAR(1000) = 'NOTHING TO THE LEFT OF THE EQUAL SIGN MATTERS = 0000000008'
SELECT
*
FROM
dbo.TEST AS C
WHERE
CUSTOMER_ID = (
CASE
WHEN @WHERE_CLAUSE IS NOT NULL
THEN LTRIM(RTRIM(SUBSTRING(@WHERE_CLAUSE, PATINDEX('%=%', @WHERE_CLAUSE)+1, LEN(@WHERE_CLAUSE))))
ELSE '1'
END)
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills