Search code examples
sqlsearchsql-server-expressfreetext

SQL Server FREETEXT search not returning any results


For some reason, I do not get a result on the SQL Server Freetext search term with the following code.

Both tables are fulltext indexed (in a catalog), and the query somehow works, but as mentioned, I don't get a result as wished...

SELECT [Col8], [Col3]
FROM [Table1]
LEFT JOIN [Table2] ON FREETEXT ([Table1].[Col8] , '[Table2].[Col3]')

Table 1:

ID Col7 Col8 Col9
1 123 123 123
2 456 456 456
3 789 789 789
4 0 anyText anyText

Table 2

Col1 Col2 Col3 Col4
1 123 123front 123behind
2 123 middle123middle middle123middle
3 456 456 456
4 456 midle456
5 789 middle789middle middle7889

Result:

Col8 Col3
123 NULL
456 NULL
789 NULL
anyText NULL

I want to find any value in Table2 which matches a value from Table 1, e.g., when I search for "123" (Col8 in Table1), then I would like to get as result (from Col3 in Table2):

123front    and
middle123middle

Solution

  • select  *
    from [Table1], [Table2]
    where [Table2].[Col3] LIKE '%' + [Table1].[Col8] + '%'