culldog88
culldog88

Reputation: 93

Replacing all doubles quotes from SQL table

Im trying to remove all instances of double quotes from an entire SQL table, and replace these double quotes " " with signle quotes ' '. Is there an efficient way to do this? thanks!

Upvotes: 0

Views: 1747

Answers (3)

If you just want to select that column without any double quote in it:

SELECT *,REPLACE(columnname, '"','') FROM tableName 

If you want to update you column by replacing all the double quote(") then Gordon provided you the right answer.

update tablename select columnname = replace(columnname, '"', '') WHERE charindex('"',columnname)>0

Upvotes: 1

Stu
Stu

Reputation: 32614

To replace double quotes with single quotes, simply do

Update table
set column=replace('"','''')
where column like '%"%'

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1270873

If you want to change the column names, you would need to update the table:

update tablename
    select column_name = replace(column_name, '"', '')
    where column_name like '%"%';

Upvotes: 0

Related Questions