title: Like operator and Trailing spaces in SQL Server
body: <p>This one matches <code>column_name like 'CharEndsHere%'</code> </p>
  
  <p>and </p>
  
  <p>This one doesn't <code>column_name like 'CharEndsHere'</code></p>
  
  <p>I know that like operator will consider even the trailing spaces, so I just copied the <strong>exact column value</strong> (with trailing spaces) and pasted it. </p>
  
  <p>Something like <code>column_name like 'CharEndsHere  '</code> yet it doesn't match -- <strong>why?</strong>. </p>
  
  <p>I haven't used <code>'='</code> operator since the columns type is <code>ntext</code></p>
  
  <p>Is there something I am missing here or shouldn't I use <code>like</code> operator in this way?</p>
  
  <p>Edited : <code>column_name like 'CharEndsHere__'</code> (__ denoted the spaces) <code>'CharEndsHere  '</code> is the exact value in that cell, using <code>like</code> in this way valid or no?</p>
  
  <p>Edit :</p>
  
  <p>This is the code I tried,</p>
  
  <pre><code>SELECT * 
  FROM [DBName].[dbo].[TableName] 
  WHERE [DBName].[dbo].[TableName].Address1 LIKE rtrim('4379 Susquehanna Trail S  ') 
  </code></pre>
  
  <p>I have also tried without using <code>rtrim</code>, yet the same result</p>
  
  <p>Edit: According to Blindy's answer,</p>
  
  <pre><code>If a comparison in a query is to return all rows with the string LIKE 'abc' (abc
  without a space), all rows that start with abc and have zero or more trailing 
  blanks are returned.
  </code></pre>
  
  <p>But in my case, I have queried, <code>Like 'abc'</code> and there is a cell containing <code>'abc '(with trailing spaces)</code> which is not returned. That's my actual problem</p>