MSSQL Escape Character

February 25th, 2009
By: Cory Mathews

Here is something that got me for a while today, escaping characters in MsSQL. I went through and tried the normal \ then thought I was losing it and tried the other slash /. However for some odd reason Microsoft went with the single tick ‘.

So for example a mssql query using the escape character might look like

SELECT a FROM b WHERE a = 'cory''s'

Notice the double tick to escape the apostrophe. Really quite simple but still really weird.