Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6549439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:05:35+00:00 2026-05-25T12:05:35+00:00

This is a T-SQL question. I have a select statement where i take a

  • 0

This is a T-SQL question.

I have a select statement where i take a list of cities and comma delimit them, then put them into a temp table. However, one of my cities is Couer D’Alene, which has an apostrophe in its name, and SQL is not liking that – no results are returned. How can I modify this to accept city names with apostrophes? Thanks!

Declare @vCity varchar(1000)

Select @vCity= ',' + @vCity+ ','

create table #Cities
(
    cityName varchar (1000)
)

Insert Into #Cities
Select  cityName
From cityTable
Where  @vCity Like  '%,' + cityName + ',%'
Group By cityName
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:05:36+00:00Added an answer on May 25, 2026 at 12:05 pm

    You need to escape the ' with another ':''

    Easiest way is the REPLACE function:

    Select @vCity= ',' + REPLACE(@vCity,'''', '''''' ) + ','
    

    All the extra ' are escaping several layers deep.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Bit of a complicated SQL question here. I currently have a SELECT statement which
I have this working SQL statement: select oriseqs.newID from oriseqs WHERE oriseqs.singlets=1 AND oriseqs.newID
If i have a parameterized SQL statement like this: SELECT * FROM table WHERE
I have a similar question to this one SQL products/productsales I want to do
This is sort of SQL newbie question, I think, but here goes. I have
I have this question in which I have a SQL Server Compact Edition database
This question might be kind of elementary, but here goes: I have a SQL
The answer to another SO question was to use this SQL query: SELECT o.Id,
I have a sql function that does a simple sql select statement: CREATE OR
I have SQL statement: SELECT ASIN, Date, DateSoldActualized, FNSKU, ItemName, MaxShipmentDateAllSkus, MaxShipmentDateThisSKU, MerchantID, MerchantSKU,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.