0
I’m performing a query for a client where it requested that the CNPJ/CPF of companies/customers be displayed without the dots, bars and dashes.
For example the CNPJ 08.595.551/0001-57
should be shown 08595551000157
.
I tried using the command REPLACE
as follows:
REPLACE(E.[CNPJ/CPF],'.', '')
However it only works for one of the characters, there is some way to remove all so that only the numbers are displayed?
The same ideal would be to record without it in the database, and let the interface take care to present the data with dots and etc.
– Lucas
I agree with @Lucas, the best way is to clean the database and then use a function (sql or code) to apply the mask
– aa_sp
Actually it would be much easier, however it uses an ERP system that when registering customers already adds with points and everything else.
– Paulo Abdanur
As of 2017 version of SQL Server is available the TRANSLATE function, which allows to execute the action with a single call to the function.
– José Diz