title: Trim dates from end of field if they exist in sql server
body: <p>I have an issue in SQL Server where I have a column that has a list of names that may or may not have a date of birth at the end. This column is then mail merged into a template that requires that only the name be displayed and not the date of birth.</p>
  
  <p>The issue I am having is that, if all rows contain name and date of birth values, I could trim the dates of birth off the end. However, in cases where there is no date of birth on the end, how do I tell SQL to leave these rows alone and not trim the ends off?</p>
  
  <p>eg:</p>
  
  <pre><code>COLUMN_NAME
  John Doe 01/01/1990
  Jane Smith 31/12/1991
  Bob Fossil
  </code></pre>
  
  <p>My current code:</p>
  
  <pre><code>select ..., left (COLUMN_NAME, len(COLUMN_NAME) - 10) 
  FROM...
  </code></pre>
  
  <p>This will take the dates of birth off John Doe and Jane Smith correctly, but I then end up with a blank for Bob Fossil (as it is 10 characters).</p>