Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace Function

Status
Not open for further replies.

sandylou

Programmer
Jan 18, 2002
147
0
0
US
I am trying to replace any occurrences of an appostrophe before i insert the values into a table.

Code:
 Replace([Title],''',Space(0))

Which gives me the following error: Unclosed quotation mark before the character string '

How do you use the replace function when you are trying to find an appostrophe?


 
When looking for an apostrophe you need to double it ie

Code:
Replace([Title],'[COLOR=red]''[/color]',Space(0))
 
THANKS!!

Declare @string char(20)
Set @string = 'Children' + '''' + 's Aid'
Print @string
SET @STRING = Replace(@string,'''',Space(0))
Print @string

 
Pleasure.

By the way, you could also change SPACE(0) to just '' if you wanted.

 
Try this buddy

Select Replace('AB''CDE', '''', 'zzz')
go

After execution we get

ABzzzCDE

9We are replacing the apostrophes with 'zzz'
 
Also, you could try enclosing in []

Replace([Title],'[']',Space(0))
 
cmmrfrds, FYI, your syntax using square brackets is invalid.

--James
 
Thank you, JamesLean, I had my syntax mixed up with Access. Although, I did find that the char() function will work similar to Access - chr(39) in Access.


Replace([Title],char(39),Space(0))


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top