suresh0534 (3/9/2015)
Hi,I got the Solution.
Below is the Solution.
DECLARE @STR VARCHAR(400)
--Add your specialcharacters here
DECLARE @specialchars VARCHAR(50) = '%[~,@,#,$,%,&,*,(,),.,!^?:]%'
SET @STR = 'KRA!NTHI@#KUMAR, KU%^?MAR GO~()$U.:D'
WHILE PATINDEX( @specialchars, @STR ) > 0
---Remove special characters using Replace function
SET @STR = Replace(REPLACE( @STR, SUBSTRING( @STR, PATINDEX( @specialchars, @STR ), 1 ),''),'-',' ')
SELECT @STR
You don't need commas between every character in @SpecialCharacters. Also, what will you do for special characters that you've left out and the special characters that don't even show up on the usual 101 style keyboard? Last but not least, how are you proposing cleaning a whole column of strings?
I know how to do those things but I'm interested in what your solution would be for those things.
--Jeff Moden
Change is inevitable... Change for the better is not.