title: Searching for terms within a query text parameter
body: <p>I have a simple table in SQL Server (I'm using 2008 R2):</p>
  
  <pre><code>Sites ( SiteId, Name )
  </code></pre>
  
  <p>Say I have the following data:</p>
  
  <pre><code>-----------------------------------------
  - SiteId - Name                         -
  -----------------------------------------
  -      1 - Foo Bar Baz                  -
  -      2 - Qux Tar                      -
  -      3 - Contoso                      -
  -----------------------------------------
  </code></pre>
  
  <p>I want to allow a user to search for "<code>baz foo</code>" and it returning row 1. I want SQL Server to break an input string up and return only rows where the column value matches all of the criteria.</p>
  
  <p>Logically, this would be something like this:</p>
  
  <pre><code>function Search(query) {
      query = query.Split(" ");
      sql = "SELECT ..."
      foreach(term in query) {
          sql += "WHERE Name LIKE " + term + " AND ";
      }
      executeSql( sql );
  }
  </code></pre>
  
  <p>I understand that T-SQL makes working with arrays very difficult, but surely there must be some built-in construct that performs tokenization/term-matching?</p>