Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
bpuccha
Starting Member
34 Posts |
Posted - 2012-09-13 : 15:35:53
|
Hi,How to check only the below special characters in a string "\", "/", ":", "?", CHR(34), "*", "<", ">", "|", "'", "." and "," |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-09-13 : 15:44:29
|
If you are interested just in detecting the existence of those special characters, you can do something like this - I have inserted only a few of the characters in your list in the like clause, you will need to insert them all.DECLARE @string VARCHAR(32) = 'abcdr:x';SELECT CASE WHEN @string LIKE '%[\/:?]%' THEN 'Special chars exist' ELSE 'No special chars found' END If you need more information, what are the kinds of information you need? |
|
|
bpuccha
Starting Member
34 Posts |
Posted - 2012-09-13 : 15:50:35
|
I just want to detect whether it has any of those special characters or not, I tried that but it not allowing "'" and CHAR(34)(").How to include those to into the list? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
bpuccha
Starting Member
34 Posts |
Posted - 2012-09-13 : 16:28:00
|
tried below code..It worked fine..Thanks if replace(substring('@tmpvariable',1,10),' ' ,'') like '%[\/:?*<>|.,''''"]%'beginprint 'it has special chars'endelsebeginprint 'it doesnt have special chars'end |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-13 : 16:48:11
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|