I want remove special character from CustomerId
column.
Currently CustomerId
column contains ¬78254782
and I want to remove the ¬
character.
Could you please help me with that ?
CodePudding user response:
SQL Server does not really have any regex support, which is what you would probably want to be using here. That being said, you could try using the enhanced LIKE
operator as follows:
UPDATE yourTable
SET CustomerId = RIGHT(CustomerId, LEN(CustomerId) - 1)
WHERE CustomerId LIKE '[^A-Za-z0-9]%';
Here we are phrasing the condition of the first character being special using [^A-Za-z0-9]
, followed by anything else. In that case, we substring off the first character in the update.
CodePudding user response:
Applying the REPLACE T-SQL function :
SELECT REPLACE(CustomerId, '¬', '') FROM Customers;