title: SQL Address Parsing
body: <p>I have a query where I'm parsing for unit # from some addresses.</p>
  
  <pre><code>CASE WHEN Address1 LIKE '%apt %' THEN SUBSTRING(Address1, CHARINDEX('Apt', Address1), LEN(Address1))
  </code></pre>
  
  <p>This works as it should when the address is set up as: "123 Main St. Apt. 1A". </p>
  
  <p>I will get "Apt. 1A" as my result.</p>
  
  <p>However, there are some instances where my data is set up differntly, an example of this would be "Apt. 2B 123 Fake Street". When the data is set up like this I get "Apt. 2B 123 Fake Street"</p>
  
  <p>The result I'm looking for is "Apt. 2B"</p>
  
  <p>How do I get my query to get the "Apt." text and all of the following text up to the next space? </p>