Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7850635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:55:26+00:00 2026-06-02T18:55:26+00:00

I want to do a SELECT statement where I replace every () with a

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:55:29+00:00Added an answer on June 2, 2026 at 6:55 pm

    I think your only sensible option is to use replace on every column individually.

    SELECT
        REPLACE(firstColumn, '"', '\"'),
        REPLACE(secondColumn, '"', '\"')
    FROM testTable
    

    You could possibly do some clever pivoting of the data in order to only apply the REPLACE once but I don’t see the benefit.

    If the actual replace you are doing is very complex then you could write a function to do it to save code clutter and duplication.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to replace two things in one select statement. Now I can replace
I have to following SQL Statement that I want to conver to LINQ Select
hi i want to select multiple db from linq in same select statement //
I want to write a SELECT statement as follows: SELECT field_a FROM my_table WHERE
In a SELECT statement I want to convert values to strings ie. SELECT TO_STRING(value).
I want to know how to visually group the results of a SELECT statement.
I have a select statement and in a couple of the fields, I want
I have a select statement, retrieve about 1000 record I want to modify it
I want to execute simple statement: SELECT * FROM OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Text;Database=C:\Temp\;','SELECT * FROM [test.csv]') And
I want to create the following T-SQL statement: SELECT SUM (sa.Amount) as 'SumAmount', SUM(sa.Cost)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.