Check for a list of special characters in a column

  • I have a list of special characters .

    I want to check if one particular column has any of those,they are like 20 characters I want to check.

    Is there a better way to do it othan than checking with like individually?

    Select *

    from testname

    where firstname like '@'

    or like '%'

    etc.

    I have to check from the list

  • yes you can, SQL supports some regular expressions:

    WITH

    MyLastNames(LName) AS

    (

    Select 'DeCaprio@gmail' UNION ALL

    Select 'Pitt[phone]' UNION ALL

    Select 'Schwarzenegger(phone)' UNION ALL

    Select 'Wahlberg' UNION ALL

    Select 'Damon' UNION ALL

    Select 'Willis'

    )

    SELECT

    B.LName

    FROM MyLastNames B

    WHERE B.LName LIKE '%[!@#$%^&*()]%'

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks it works

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply