views:

398

answers:

2

I'm looking for the db2 equivalent of T-SQL's:

INSERT INTO People (Surname) VALUES ('O''Hara');
+1  A: 

Use two apostrophes '' to get a single apostrophe on DB2 too, according to the DB2 Survival Guide. Isn't that working for you?

Brabster
Doh! you are correct, I overlooked a few apostrophes that needed escaping...
grenade
I was sure I'd done that before on DB2 but don't have a DB2 instance to hand! Glad you figured it out.
Brabster
A: 

Brabster is correct. You are supposed to escape ' with ''
So to insert O'Hara , you will have to write O''Hara
Excerpt from: http://www.michael-thomas.com/tech/db2/db2_survival_guide.htm

Escape character.

To insert a single quote, use 2 single quotes ( '' ). To insert pet's use the following pet''s.
Example: insert into MYTABLE (question,answer) values ('What is your pet''s name?','blacky') `

Rakesh Juyal