gizgok
gizgok

Reputation: 7649

How to get column which might contain special characters in sql server

I have a situation where the name column comprises of many special characters. I have a solution where I do Like with all the special characters mentioned like this '%[''",/#$!-@%^&*.\+-]%'` But this I think is not a good way to solve the problem. Is there a way where I can use Regular Expression within SQL query itself for checking if the name column contains special characters or not. Special characters would be everything apart from alphabets and numbers.

I know Regex can be used with C# and T-SQL. Looking for something if can be done through native SQL

Upvotes: 4

Views: 9416

Answers (2)

Martin Smith
Martin Smith

Reputation: 453940

You can use

 WHERE yourcolumn LIKE '%[^0-9a-zA-Z]%' COLLATE Latin1_General_BIN

Upvotes: 7

Related Questions