How to escape single quotes in Sybase

Pez Cuckow picture Pez Cuckow · Sep 21, 2012 · Viewed 23.7k times · Source

I come from MySQL and the below query doesn't work in Sybase. How should I escape single quotes?

UPDATE Animals SET NAME = 'Dog\'s friends' WHERE uid = 12

Answer

Pez Cuckow picture Pez Cuckow · Sep 21, 2012

If working with Sybase, having got used to MySQL which more database users have experience you may soon discover you are unable to escape single quotes with backslash in.

So how do you escape quotes in Sybase? In fact, in Sybase SQL the single quote acts as the escape character.

See below for an example UPDATE statement in both “languages”:

MySQL

UPDATE Animals SET NAME = 'Dog\'s friends' WHERE uid = 12

Sybase

UPDATE Animals SET NAME = 'Dog''s friends' WHERE uid = 12

I’m not entirely sure this makes sense to me (especially as it looks like a double quote) but there you go!