cancel
Showing results for 
Search instead for 
Did you mean: 

Data error during insert of data with "'" in database

dru_marcellana
Participant
0 Kudos

Hi all!

  I am trying to insert a data with single quote (') and I think this causes the command sql query for inserting the data to fail.

  Is there a way on how to avoid this?

  Thanks!

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Dru,

Inserting a string in SQL DB with single quote gives an error.But there are some cases where we cannot eliminate it and it becomes mandatory to insert a single quote.Just replace single quote ( ' ) with two single quotes (not a double quote).The first single quote is used as an escape character and only one single quote goes to the DB.

Hope it works..

Regards,

Anuj

agentry_src
Active Contributor
0 Kudos

Hi Dru,

This is an issue with the SQL side since a single tick mark (single quote) is used to specify a literal string.  You can do a string replace for that property prior to passing the SQL to your database.  What you replace it with will take some testing, but you will likely need to use escape characters recognized by your database.  Or you can clean up the data and train the users to not use special characters, but that is like tilting at windmills in real life.  (i.e. Don't bother trying to be Don Quixote).

Regards, Mike