Reputation: 41
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 ?
Upvotes: 0
Views: 2442
Reputation: 447
Applying the REPLACE T-SQL function :
SELECT REPLACE(CustomerId, '¬', '') FROM Customers;
Upvotes: 4
Reputation: 522626
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.
Upvotes: 2