Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Check for a list of special characters in a column Expand / Collapse
Author
Message
Posted Friday, December 13, 2013 9:43 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 1:17 PM
Points: 15, Visits: 38
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
Post #1522772
Posted Friday, December 13, 2013 9:50 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 8:07 PM
Points: 12,910, Visits: 32,028
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1522775
Posted Monday, December 16, 2013 8:09 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 1:17 PM
Points: 15, Visits: 38
Thanks it works
Post #1523251
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse