Removing nonnumerical data out of a number + SQL

前端 未结 5 1894
深忆病人
深忆病人 2021-01-21 06:06

I\'m trying find the best way to remove nonnumerical data from a varchar in SQL e.g.

\'(082) 000-0000\' to \'0820000000\' or
\'+2782 000 0000\' to \'0820000000\'         


        
5条回答
  •  醉酒成梦
    2021-01-21 06:55

    It is much easier to handle string parsing in your business layer. However, baring that use the T-SQL REPLACE() function (assuming MS SQL).

    You could do a loop with that function on the parameter that was passed in to strip all non-numeric letters out of it.

提交回复
热议问题