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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Has anyone found a way to do an insert with an apostrophe

Status
Not open for further replies.

bigfoot

Programmer
May 4, 1999
1,779
US
I have an old wound that wont heal. It concerns doing an insert with values that have an apostrophe in them
Example Gary's Garage would blow up SQL

Has anyone found a way around this?
 
You can imbed single quotes using an additional quote in the string. Your example would work like this:

insert...
select 'Gary''s Garage'

For quotes at the end of a string, you will need to add an additional quote. If you wanted "The ball is Chris'" (it is the best example i can think of). You should enter:

insert ...
select 'The ball is Chris'''
 
I find this bit of code useful.

replace(Request.Form("FieldName"), "'", "''")
 
For what it is worth.

A single quote ['] (ascii 39) is not an apostrophe [`] (ascii 96).

They are two distinct characters with differenct ascii values. However millions of sloppy data entry perople and typists do not know the difference.

What I tend to do in my applications is replace single quotes with apostrophies in character fields before doing the insert, thereby avoiding the problem in the first place.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top