title: How to replace &amp; to & in SQL?
body: <p>I have some bad data in my database table. I want to replace all <code>&amp;amp;</code> or <code>&amp;amp;amp;</code> or <code>&amp;amp;amp;amp</code> or <code>&amp;amp;amp;amp;amp</code> to <code>&amp;</code> only.</p>
  
  <p>In java it is working fine. how to do in SQL? </p>
  
  <p>Java:</p>
  
  <pre><code>    String[] names = new String[] { "Ravi Suthar", 
                                      "Ravi &amp;amp; Suthar", 
                                      "Ravi &amp;amp;amp; Suthar",
                                      "Ravi &amp;amp;amp;amp; Suthar",
                                      "Ravi &amp;amp;amp;amp;amp; Suthar" };
  
      for (String name : names) {
          System.out.println(name.replaceAll("&amp;amp;[amp;]*", "&amp;"));
      }
  </code></pre>
  
  <p>SQL:</p>
  
  <pre><code>UPDATE tablename SET columnname=REPLACE(columnname,'&amp;amp;[amp;]*','&amp;');
  </code></pre>