Reputation: 918
I have a varchar
field LOCATIONCITY
and there is a value
St. John''s
I want to search it like following
select * from city where locationcity='St. John''s'
Since it's a default behavior of sql server that double single quotes are converted to single double qoites
How can I search for 'St. John''s'
Upvotes: 2
Views: 840
Reputation: 10295
Try this:
DECLARE @Name varchar(100)='St. John''s'
set @Name=REPLACE(@Name,'''','''')
select @Name
Upvotes: 1
Reputation: 311808
You have two single quotes, each one of which should be escaped by doubling it, so:
select * from city where locationcity='St. John''''s'
Upvotes: 6