Remove "." "/" and "-" from varchar in select

0

I am conducting a query for a client where he / she requested that the CNPJ / CPF of the companies / clients be displayed without the dots, bars and dashes. For example, the CNPJ 08.595.551/0001-57 should be displayed 08595551000157 .

I tried to use the REPLACE command as follows: REPLACE(E.[CNPJ/CPF],'.', '')

But it only works for one of the characters, is there any way to remove all so that only the numbers are displayed?

    
asked by anonymous 14.03.2018 / 13:55

1 answer

3

You should use multiple replaces:

REPLACE(REPLACE(REPLACE(E.[CNPJ/CPF],'.', ''),'-', ''),'/', '')
    
14.03.2018 / 13:57