How to strip all non-alphabetic characters from string in SQL Server?

后端 未结 18 1310
情深已故
情深已故 2020-11-21 23:49

How could you remove all characters that are not alphabetic from a string?

What about non-alphanumeric?

Does this have to be a custom function or are there

18条回答
  •  死守一世寂寞
    2020-11-22 00:21

    DECLARE @vchVAlue NVARCHAR(255) = 'SWP, Lettering Position 1: 4 Ω, 2: 8 Ω, 3: 16 Ω, 4:  , 5:  , 6:  , Voltage Selector, Solder, 6, Step switch, : w/o fuseholder '
    
    
    WHILE PATINDEX('%?%' , CAST(@vchVAlue AS VARCHAR(255))) > 0
      BEGIN
        SELECT @vchVAlue = STUFF(@vchVAlue,PATINDEX('%?%' , CAST(@vchVAlue AS VARCHAR(255))),1,' ')
      END 
    
    SELECT @vchVAlue
    

提交回复
热议问题