title: Don't include variable in SQL WHERE clause if it is null
body: <p>I have a query in SQL and currently if all of the values that the user enters in a textbox are null, when they click search it would just return the whole table.</p>
  
  <pre><code>SELECT Column Names
  FROM TableName
  WHERE
          FirstName LIKE '%' + @FirstName + '%'
          OR Surname LIKE '%' + @Surname + '%'
          OR City LIKE '%' + @City + '%'
          OR County LIKE '%' + @County + '%'
  </code></pre>
  
  <p>However, what I want to do is to not include for example <code>FirstName</code> if nothing is entered when searching. So if someone decided to enter "<code>London</code>" into <code>City</code> then it would return only those results that contained London. Likewise, if they entered "<code>John</code>" and "<code>London</code>" then I would like everyone called John in London to be returned.</p>