Using an apostrophe enclosed within single quotes

  • Let's say I want have Women's or Men's as in shirt sizes.  Each of these words would be enclosed within single quotes since they are text values, but the apostrophe prevents the "s" from being recognized.

    What is the correct way to deal with this w/o having to use double quotes?

  • Use a single-quote twice.

    SELECT 'Men''s Large' AS [Result]

    Eddie Wuerch
    MCM: SQL

  • Absolutely Eddie's answer, or, use parameterized queries and then you simply pass the normal string, Women's, to the parameter with no additional work required.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply