I want to do a SELECT statement where I replace every (") with a (\") in multiple columns. Now how do I do that?
Is it possible to target more than one column with the REPLACE function within a SELECT statement?
I know this is invalid code but just to visualize what I mean:
SELECT REPLACE(firstColumn, anotherColumn, '"', '\"')
FROM testTable
that of course does not work because the REPLACE function expects only three parameters.
I really need help with this as I couldn't find anything that worked for me yet.
thanks in advance!
[edit - 24.04.2012 - 16:20 UTC+01:00]
For those who might have a similar problem, this is my solution: I used regular expression to build my SELECT REPLACE statement which looks like this:
Regex: {(^[^, ]+,)}|( {[^, ]+,})|( {[^, ]+$})
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:
ID, Gender, Firstname, Lastname, Street, Zip, City, EMail, Age,
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:
REPLACE(\1\2\3 'replaceMe', 'withMe') AS \1\2\3
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!