Take the 2-minute tour ×
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. It's 100% free, no registration required.

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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