Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to remove single quotes from table

Author  Topic 

ganny
Yak Posting Veteran

51 Posts

Posted - 2010-02-10 : 07:24:05
Hi,

I am facing a problem with single quotes in my table. I just want to show the table data without single quotes as mentioned below.

My current table:
Id Name code
---------------------
10 XUUS'22CC M1
11 XUSY'33DC M1
12 DXX'44KO M2

Expected output to show:
Id Name code
---------------------
10 XUUS22CC M1
11 XUSY33DC M1
12 DXX44KO M2


Kindly help me, how to remove quotes from my table.

Thank you.



Kristen
Test

22859 Posts

Posted - 2010-02-10 : 07:25:46
[code]UPDATE U
SET [Name] = REPLACE([Name], '''', '')
FROM MyTable AS U
WHERE [Name] LIKE '%''%'
[/code]
Take a backup first.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-02-10 : 07:26:40
You can mask a single quote with a second single quote:
select
Id,
replace([Name],'''','') as [Name],
code
from table


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-02-10 : 07:27:23



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

ganny
Yak Posting Veteran

51 Posts

Posted - 2010-02-10 : 07:30:08
quote:
Originally posted by webfred

You can mask a single quote with a second single quote:
select
Id,
replace([Name],'''','') as [Name],
code
from table


No, you're never too old to Yak'n'Roll if you're too young to die.



Dear webfred, Thank you for the assistance.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-02-10 : 07:33:00
my pleasure


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-10 : 07:43:42
http://beyondrelational.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -