sql server - Find and Replace All Special Character in SQL -
this question has answer here:
i want copy row in new column replacing special character -. code below.
my table design
select * mycode update mycode set newname = replace(myname, '%[^0-9a-za-z]%', '-')
it's getting copy code special character not replaced
result
try query
declare @specialchar varchar(15) declare @getspecialchar cursor set @getspecialchar = cursor select distinct poschar master..spt_values s cross apply (select substring(newname ,number,1) poschar mycode ) t number > 0 , not (ascii(t.poschar) between 65 , 90 or ascii(t.poschar) between 97 , 122 or ascii(t.poschar) between 48 , 57) open @getspecialchar fetch next @getspecialchar @specialchar while @@fetch_status = 0 begin update mycode set newname =replace(myname,@specialchar,'') fetch next @getspecialchar @specialchar end close @getspecialchar deallocate @getspecialchar
Comments
Post a Comment