I have a table with the column
f_Name. The column
f_name sometimes contains special characters and numbers as in the examples below:
f_name ----------- Pan23's Ram'kumar lawer"s()
I want to retrieve all the values of
f_name which have a special character or number.
SELECT F_name FROM tablename WHERE F_name LIKE '%[^a-Z0-9]%'
What this does is search for
%.....% : a string [.....] : that contains any of the mentioned characters ^ : well actually none of the mentioned characters a-Z : from lower-case a through to upper-case Z 0-9 : or any digit
Which results in a search for any character other than
Strings that match this would be:
test'user something?else I#can#fly
Reference: LIKE (Transact-SQL) (Microsoft | SQL Docs)
After re-reading your question, I would use just:
SELECT F_name FROM tablename WHERE F_name LIKE '%[^a-Z]%'
…because you want to retrieve rows with numbers too.