How to get column which might contain special char

2019-05-04 06:19发布

问题:

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

回答1:

You can use

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


回答2:

http://msdn.microsoft.com/en-us/magazine/cc163473.aspx