If [Field1] contains text from [Field2] then return [Field3] as [Field4]
Can you be more specific on how to predicate [Field1] contains text from [Field2]? For example, we can say the [Field1]="Hello World" contains [Field2]="World". But what about "Hello World" and "beautiful world", can
we say this example still follows the predication for they both contain the text "world"?
The fore example can be simple, you can achieve your goal with a CASE WHEN expression.
SELECT CASE WHEN [FILED1] LIKE '%'+[FIELD2]+'' THEN FIELD3 ELSE....END
The latter example makes things in a complicated case. You would have to CROSS APPLY a table-valued function that splits the field2's every words into table and use a CHARINDEX to predicate.
Could you post your table DDL and some sample data so we can look into your question further?
If you have any feedback on our support, you can click
here.