Answer the question
In order to leave comments, you need to log in
Similar to vlookup in SQL, but with an incomplete match, any ideas?
Hello!
There are 2 tables:
You need to compare COMPARE with the PHRASE reference column, and if it matches, write ID from Table2 and IF_TRUE from Table1 to a new table. Similar to vlookup from Excel. But the difference is that you need to check the register. In the screenshot, red is false, green is a match.
In theory, there should be hundreds of thousands of such records. Does anyone have any idea how to implement this in T-SQL?
Answer the question
In order to leave comments, you need to log in
More or less like this:
SELECT ID, IF_TRUE Result
INTO Table3
FROM Table1
LEFT JOIN Table2
ON (COMPARE COLLATE SQL_Latin1_General_CP1_CS_AS) LIKE '%' + PHRASE + '%'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question