SQL Server: How do you remove punctuation from a field?

前端 未结 8 1266
甜味超标
甜味超标 2021-02-05 20:50

Any one know a good way to remove punctuation from a field in SQL Server?

I\'m thinking

UPDATE tblMyTable SET FieldName = REPLACE(REPLACE(REPLACE(FieldNa         


        
8条回答
  •  死守一世寂寞
    2021-02-05 21:09

    Can't you use PATINDEX to only include NUMBERS and LETTERS instead of trying to guess what punctuation might be in the field? (Not trying to be snarky, if I had the code ready, I'd share it...but this is what I'm looking for).

    Seems like you need to create a custom function in order to avoid a giant list of replace functions in your queries - here's a good example:

    http://www.codeproject.com/KB/database/SQLPhoneNumbersPart_2.aspx?display=Print

提交回复
热议问题