?
Solved

Repalcing Single Quotes

Posted on 2008-06-09
2
Medium Priority
?
864 Views
Last Modified: 2008-06-11
Hello All,

I am trying to replae single quotes ( ' )  with the word 'ft' in our database table.
Below is the syntax I am using:

Update Product
Set      MetaDescription = RTRIM(LTRIM(Replace(MetaDescription, ' ' ', 'ft' ))),
      LongDescription = RTRIM(LTRIM(Replace(LongDescription, ' ' ', 'ft')))

But I get the error msg:
Msg 105, Level 15, State 1, Line 2
Unclosed quotation mark after the character string '', '))) '.
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '', ')))

I have tried enclosing the single quote in double quotes as in ( " ' " ). Still no luck.

Thanks for your help.
0
Comment
Question by:godwineffiong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
dportas earned 500 total points
ID: 21746997
UPDATE Product
SET      MetaDescription = RTRIM(LTRIM(Replace(MetaDescription, '''', 'ft' ))),
      LongDescription = RTRIM(LTRIM(Replace(LongDescription, '''', 'ft')));
0
 
LVL 51

Expert Comment

by:Mark Wills
ID: 21760596
Yeah, it is a trap, you actually need 4 single quotes there is a quote at start and end, then a quote before the single quote to let it know it is definitiely a single quote (kind of like a control character)


Update Product  Set MetaDescription = RTRIM(LTRIM(Replace(MetaDescription, '''', 'ft' ))),  LongDescription = RTRIM(LTRIM(Replace(LongDescription, '''', 'ft')))

and probably (to minimise the number of changes) want a: where (metadescription like '%''%' or longdescription like '%''%')

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question