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
1.4m articles
1.4m replys
5 comments
57.0k users