How to detect if a string contains special characters like #,$,^,&,*,@,! etc (non-alphanumeric characters) in SQL server 2005?
Assuming SQL Server:
e.g. if you class special characters as anything NOT alphanumeric:
DECLARE @MyString VARCHAR(100) SET @MyString = 'adgkjb$' IF (@MyString LIKE '%[^a-zA-Z0-9]%') PRINT 'Contains "special" characters' ELSE PRINT 'Does not contain "special" characters'
Just add to other characters you don't class as special, inside the square brackets
2.1m questions
2.1m answers
60 comments
57.0k users