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

enter image description here

 select * mycode     update mycode     set newname = replace(myname, '%[^0-9a-za-z]%', '-') 

it's getting copy code special character not replaced

result enter image description here

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

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -