title: Trim everything after symbol and also search for other fields SQL
body: <p>I have a number of fields in a database that i need to pull information from. For the name column the data is in the following format:</p>
  
  <pre><code>Jim John - 1234567
  </code></pre>
  
  <p>I only want the name section, therefore trim everything from the "-" onwards. I've tried the following</p>
  
  <pre><code>"SELECT REPLACE(LEFT(name, CHARINDEX('-',name)-1),'_',' '), othername, streetname, postal, 
                                          nameID, helper, helperID
  
          FROM [DATABASE].[dbo].[nameDB] with (nolock) 
  
          WHERE
                (othername like '" &amp; txtSearch.Text &amp; "' 
                 or postal like '" &amp; txtSearch.Text &amp; "') 
                 and (postal not like '%Error%' 
                 and postal not like '%nas_admin%'
                 and postal not like '%NASAdmin%'
                 and postal like '[A-z][A-z][A-z]%')"
  </code></pre>
  
  <p>This doesn't work, is it possible that i can trim the data and also search for other data in other fields?</p>
  
  <p>Thanks for any help </p>