sql server - In string 0 to 9 number replace with blank in SQL -
sql server - In string 0 to 9 number replace with blank in SQL -
this question has reply here:
how strip non-alphabetic characters string in sql server? 13 answersi have string
208pb, 75as, 111cd
i want relapse number blank , result
pb, as, cd
source
method 1:
try function:
create function [dbo].[removenonalphacharacters](@temp varchar(1000)) returns varchar(1000) begin declare @keepvalues varchar(50) set @keepvalues = '%[^a-z]%' while patindex(@keepvalues, @temp) > 0 set @temp = stuff(@temp, patindex(@keepvalues, @temp), 1, '') homecoming @temp end
call this:
select dbo.removenonalphacharacters('208pb')
output:
pb
method 2:
declare @str varchar(400) declare @expres varchar(50) = '%[0-9]%' set @str = '208pb' while patindex( @expres, @str ) > 0 set @str = replace(replace( @str, substring( @str, patindex( @expres, @str ), 1 ),''),'-',' ') select @str
output:
pb
sql-server
Comments
Post a Comment