I am in need of a query (or stored procedure rather) for SQL Server wherein I need compare data of two different tables with the following structure
Table 1
ID Text Table2ID
1 Chris
2 John
3 Paul
Table2
ID Text
1 Mitchell Johnson
2 Chris Martin
3 Steven
By comparing the above two tables, I need to get the ‘IDs’ from table2 and insert them into the ‘Table2ID’ column of first table
Comparison criteria:-
The full word in ‘Text’ column of ‘Table1’ should be contained in ‘Text’ column of ‘Table2’
In our case, we would obtain ‘IDs’ of first two rows from table2 (since the word John is contained in ‘Mitchell Johnson’ and the word Chris is contained in ‘Chris Martin’ and Paul is not contained in ‘Table2’)
How could I achieve this? It would be nice if someone out here is able to shed light on my path
Regards,
Raghuraman.V
The abstract answer is:
Specifically: