For example, if I had a condition I needed to be met, then I need another thing done to the column values, how would I go about doing that?
CAST(
CASE WHEN TRY_CAST(CON_ORDERS_MIN.CONCAT_ITEM AS numeric) = o.ORDER_ID
THEN NULL
WHEN CHARINDEX(CAST(o.ORDER_ID AS nvarchar), CON_ORDERS_MIN.CONCAT_ITEM) > 0
--CONDITION 1
THEN REPLACE(CON_ORDERS_MIN.CONCAT_ITEM, CAST(o.ORDER_ID AS nvarchar), '')
--CONDITION 2
THEN replace(ltrim(rtrim(replace(replace(replace(replace(col, ',', '><'), '<>', ''), '><', ','), ',', ' '))), ' ', ',')
ELSE CON_ORDERS_MIN.CONCAT_ITEM
END AS VARCHAR
)AS EXAMPLE
I'm asking "when this number is found in this list of numbers, then remove that number and get rid of the commas." So when it's found, replace that with nothing and clean up the commas. And I don't really understand the long nested replacey thing. In fact, it hurts my brain to look at it. Does anyone have a better way to do this?
Data example:
ID_TB_SEARCHED CSV_IDS
1234567 1234567, 8900123, 12349786
What i am trying to achieve:
ID_TB_SEARCHED CSV_IDS
1234567 8900123, 12349876
Edit: Also, i know that the second replace function isn't correct. I just copied it and pasted.