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 496749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:42:56+00:00 2026-05-13T05:42:56+00:00

I was actually asked this myself a few weeks ago, whereas I know exactly

  • 0

I was actually asked this myself a few weeks ago, whereas I know exactly how to do this with a SP or UDF but I was wondering if there was a quick and easy way of doing this without these methods. I’m assuming that there is and I just can’t find it.

A point I need to make is that although we know what characters are allowed (a-z, A-Z, 0-9) we don’t want to specify what is not allowed (#@!$ etc…). Also, we want to pull the rows which have the illegal characters so that it can be listed to the user to fix (as we have no control over the input process we can’t do anything at that point).

I have looked through SO and Google previously, but was unable to find anything that did what I wanted. I have seen many examples which can tell you if it contains alphanumeric characters, or doesn’t, but something that is able to pull out an apostrophe in a sentence I have not found in query form.

Please note also that values can be null or '' (empty) in this varchar column.

  • 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-13T05:42:56+00:00Added an answer on May 13, 2026 at 5:42 am

    Won’t this do it?

    SELECT * FROM TABLE
    WHERE COLUMN_NAME LIKE '%[^a-zA-Z0-9]%'
    

    Setup

    use tempdb
    create table mytable ( mycol varchar(40) NULL)
    
    insert into mytable VALUES ('abcd')
    insert into mytable VALUES ('ABCD')
    insert into mytable VALUES ('1234')
    insert into mytable VALUES ('efg%^&hji')
    insert into mytable VALUES (NULL)
    insert into mytable VALUES ('')
    insert into mytable VALUES ('apostrophe '' in a sentence') 
    
    SELECT * FROM mytable
    WHERE mycol LIKE '%[^a-zA-Z0-9]%'
    
    drop table mytable 
    

    Results

    mycol
    ----------------------------------------
    efg%^&hji
    apostrophe ' in a sentence
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Actually I am working on this for the last 3 or 4 weeks but
I know this sort of question has been asked before , but I still
Actually I have already asked this question in official Q&A but didn't get any
A few days ago i asked this question: Displaying images from Facebook photo albums
I know I've asked this question before, and I know there are plenty of
I had asked this question on Javaranch , but couldn't get a response there.
I know this has been asked here before but my conditions are a little
I've asked this question before but never actually got it working. More or less,
I've actually asked this question before, but haven't achieved success with it back then,
I know this has been asked millions of times and I've had it myself

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.