title: How to convert empty spaces into null values, using SQL Server?
body: <p>I have a table and the columns on this table contains empty spaces for some records. Now I need to move the data to another table and replace the empty spaces with a <code>NULL</code> value.  </p>
  
  <p>I tried to use:</p>
  
  <pre><code>REPLACE(ltrim(rtrim(col1)),' ',NULL)
  </code></pre>
  
  <p>but it doesn't work. It will convert all of the values of <code>col1</code> to <code>NULL</code>. I just want to convert only those values that have empty spaces to <code>NULL</code>.</p>