w3n2u w3n2u - 1 year ago 70
SQL Question

How to remove the first character if it is a specific character in SQL

I currently have a table

it has entries like the following:


What I want to do is remove only the 9 from the start of all the entries that have a 9 there but leave the others as they are.

any help would be greatly appreciated.

Answer Source

While all other answer are probably also working, I'd suggest to try and use STUFF function to easily replace a part of the string.

UPDATE Telephone
SET number = STUFF(number,1,1,'')
WHERE number LIKE '9%'


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download