Skip to content
Advertisement

Return sql rows where field contains ONLY non-alphanumeric characters

I need to find out how many rows in a particular field in my sql server table, contain ONLY non-alphanumeric characters.

I’m thinking it’s a regular expression that I need along the lines of [^a-zA-Z0-9] but Im not sure of the exact syntax I need to return the rows if there are no valid alphanumeric chars in there.

Advertisement

Answer

SQL Server doesn’t have regular expressions. It uses the LIKE pattern matching syntax which isn’t the same.

As it happens, you are close. Just need leading+trailing wildcards and move the NOT

 WHERE whatever NOT LIKE '%[a-z0-9]%'
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement