How to detect if a string contains special characters like #,$,^,&,*,@,! etc in SQL server 2005?
A:
In postgresql you can use regular expressions in WHERE clause. Check http://www.postgresql.org/docs/8.4/static/functions-matching.html
MySQL has something simmilar: http://dev.mysql.com/doc/refman/5.5/en/regexp.html
skyman
2010-04-01 07:25:28
+4
A:
SELECT * FROM tableName WHERE columnName LIKE "%#%" OR columnName LIKE "%$%" OR (etc.)
Brendan Long
2010-04-01 07:25:39
+1 : for etc. ;)
Manish
2010-04-01 07:33:17
+4
A:
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
AdaTheDev
2010-04-01 07:27:00