title: Calculating the number of similar words between two strings in SQL
body: <p>I am planning to write a TSQL function of two input strings and a percentage of words similarity as an output, For example :</p>
  
  <pre><code>SELECT [dbo].[FN_CalcSimilarWords]('Golden horses hotel','Hotel Golden Horses')
  </code></pre>
  
  <p>Returns :</p>
  
  <pre><code>3/3
  </code></pre>
  
  <p>or</p>
  
  <pre><code>SELECT [dbo].[FN_CalcSimilarWords]('Golden horses','Golden horses Malaysia')
  </code></pre>
  
  <p>Returns :</p>
  
  <pre><code>2/3
  </code></pre>
  
  <p>I was thinking about looping and comparing the words after parsing the strings to <a href="http://www.codeproject.com/Tips/666620/T-SQL-Most-Practical-Split-Function" rel="nofollow">This split function</a>, Any other ideas for a better performance?</p>