Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, November 30, 2015 4:17 AM
Points: 34, Visits: 76
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: Yesterday @ 9:47 PM
Points: 14,437, Visits: 37,834
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!
Post #1522775
Posted Monday, December 16, 2013 8:09 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, November 30, 2015 4:17 AM
Points: 34, Visits: 76
Thanks it works
Post #1523251
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse