Inserting Strings with Apostrophes Into SQL Server

Strings in SQL Server are enclosed in single quotes. So if you have a string such as a person’s name like O’Mally, then the string would be ‘O’Mally’.  This obviously breaks the SQL statement.  To overcome this issue you need escape the apostrophe by doubling it up.  So to use our previous example the modified string would be ‘O”Mally’.