title: How do I replace the same thing in multiple columns within a SELECT statement in SQL?
body: <p>I want to do a <strong>SELECT</strong> statement where I replace every (") with a (\") in <strong>multiple columns</strong>. Now how do I do that?</p>
  
  <p>Is it possible to target more than one column with the REPLACE function within a SELECT statement?</p>
  
  <p>I know this is <strong>invalid</strong> code but just to visualize what I mean:</p>
  
  <pre><code>SELECT REPLACE(firstColumn, anotherColumn, '"', '\"') 
  FROM testTable
  </code></pre>
  
  <p>that of course <strong>does not work</strong> because the REPLACE function <em>expects only three parameters</em>.</p>
  
  <p>I really need help with this as I couldn't find anything that worked for me yet.</p>
  
  <p>thanks in advance!</p>
  
  <p><strong>[edit - 24.04.2012 - 16:20 UTC+01:00]</strong></p>
  
  <p>For those who might have a similar problem, this is my <strong>solution</strong>: I used <em>regular expression</em> to build my <strong>SELECT REPLACE</strong> statement which looks like this:</p>
  
  <pre><code>Regex: {(^[^, ]+,)}|( {[^, ]+,})|( {[^, ]+$})
  </code></pre>
  
  <p>In order to use this you need all your columns you want to go through each seperated with a comma and a space like this:</p>
  
  <p><code>ID, Gender, Firstname, Lastname, Street, Zip, City, EMail, Age,</code></p>
  
  <p>and then you need a tool (in my case Visual Studio) that is capable of replacing with tagged expressions (between the {} brackets in regex) and replace it with something like this:</p>
  
  <p><code>REPLACE(\1\2\3 'replaceMe', 'withMe') AS \1\2\3</code></p>
  
  <p>Hope this helps anyone who might have a similar problem. It is probably not the best solution but it worked for me. Thanks for the quick help!</p>