TSQL Challenge 34




TSQL Challenge 34 - Search for two keywords within the maximum distance of one word between them

This challenge is all about searching for two keywords in a string with a maximum distance of 'one word' between them.

For example, if 'sql' and 'server' are the keywords, a match will be found on 'Microsoft SQL Server 2008' as well as on 'I like sql and server'. The second phrase matches because there is only one word between 'sql' and 'server' which is acceptable.

Note also that the search keywords can occur in any order within the string. If you search for 'sql' and 'server' a match can be found in 'Exchange Server runs SQL' because both the keywords occur in the string within the distance of one word ('runs').