Solved

Repalcing Single Quotes

Posted on 2008-06-09
2
837 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
2 Comments
 
LVL 22

Accepted Solution

by:
dportas earned 125 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Return 0 on SQL count 24 30
CPU high usage when update statistics 2 30
Connecting to multiple databases to create a Dashboard 5 26
Highest and 2nd Highest Totals 11 22
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how the fundamental information of how to create a table.

831 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