Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using SQL server 2005 and using the northwind database. I need the supplier id of Grandma Kelly's Homestead and I used this query:

select supplierid from suppliers
where companyname ='Grandma Kelly''s'' Homestead'

I checked the link Escaping a single quote in sql server, but I can't find an answer.

I used the two single quotes but it didn't work since the query is executing but it doesn't return a value.

How can I escape the single quote and retrieve the value? I would also like to know how to insert the values into the table having quotes

share|improve this question

closed as off-topic by Colin 't Hart, Paul White, Vérace, dezso, Michael Green Jun 18 '15 at 11:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Colin 't Hart, Paul White, Vérace, dezso, Michael Green
If this question can be reworded to fit the rules in the help center, please edit the question.

Should it be = 'Grandma Kelly''s Homestead'? No apostrophe(s) after the "s" (which don't make sense in English anyway. – Vérace Jun 18 '15 at 9:54
up vote 5 down vote accepted

I think you just meant:

select supplierid from dbo.suppliers
where companyname ='Grandma Kelly''s Homestead';

(In other words, there was only one apostrophe to replace.)

share|improve this answer
thanks bertrand it worked – Biju jose Aug 10 '12 at 4:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.