Solved

Repalcing Single Quotes

Posted on 2008-06-09
2
857 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 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

695 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