3

I need to change

ABC2001  
ABCD2001 
ASDF111111

to

2001
2001
111111

I need to remove alphabetic characters in SQL Server, any idea?

  • Probably a duplicate of this question... http://stackoverflow.com/questions/1007697/how-to-strip-all-non-alphabetic-characters-from-string-in-sql-server You can use the function from the answer of that question to update your table. – Kevin DiTraglia May 18 '12 at 17:09

1 Answers1

0

The function below will take care

create function NoLetters(@string2number varchar(200)) 
 returns varchar(200)
as
begin
  declare @c int
  declare @num varchar(200)
  set @num = ''
  declare @txtCurrent char(1)
  set @c=1
  while @c<=len(@string2number)
    begin
     set @txtCurrent = substring(@string2number,@c,1)
     if ascii(@txtCurrent) between 48 and 57
       set @num = @num + @txtCurrent
     set @c=@c+1
   end
 return @num
end
sumit
  • 15,003
  • 12
  • 69
  • 110