title: Fuzzy string matching SQL - words in different order
body: <p>How to match strings which are not exact and have a different order of words. Usually the strings have similar digit patterns but the words may be in different order.</p>
  
  <p>For example, I would consider a good matching of strings:</p>
  
  <p><strong>Target string</strong>: <code>Apple 10mg/51L Tail</code></p>
  
  <p><strong>Test string</strong>: <code>Tail 10mg/51L Apple</code> (just shuffle of words, correct spelling)</p>
  
  <p>I would also consider a good match between the following strings:</p>
  
  <p><strong>Test string</strong>: <code>51L MissleadingLENWord ObfuscateTail 10mg Apple</code> (all the words of target string can be found in the test string if we check each word one by one with LIKE clause i.e. "Tail" of target string can be found in test string in word "ObfuscateTail").</p>
  
  <p>I would like to see the solution of this problem in the function returning the percentage number, which means how similar the strings are - zero - the strings are different, 100% both strings are the same. </p>
  
  <p>Which algorytm should I use? Best if it could be implemented with SQL Server. </p>
  
  <p>I could find some algorithms proposed here: <a href="https://stackoverflow.com/questions/921978/fuzzy-matching-using-t-sql">Fuzzy matching using T-SQL</a>.
  Is the <strong>Levenshtein</strong> distance algorithm mentioned in leading answer appropriate for mixed order of words?</p>