Escaping Single Quotes in Sybase T-SQL

Most individuals having database experience with MySQL will find shortly after using Sybase DBMS that the backslash character does not escape characters. Instead in Sybase T-SQL the single quote itself acts as the escape character. Below is a sample UPDATE statement showing the difference in escaping the single quote character in MySQL and Sybase.

MySQL

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
UPDATE COMPANY SET NAME = 'Joseph's Shoes' WHERE ID = 3
UPDATE COMPANY SET NAME = 'Joseph's Shoes' WHERE ID = 3
UPDATE COMPANY SET NAME = 'Joseph's Shoes' WHERE ID = 3

Sybase

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
UPDATE COMPANY SET NAME = 'Joseph''s Shoes' WHERE ID = 3
UPDATE COMPANY SET NAME = 'Joseph''s Shoes' WHERE ID = 3
UPDATE COMPANY SET NAME = 'Joseph''s Shoes' WHERE ID = 3
// T-SQL // Tips & Tricks //

Comments & Questions

Add Your Comment