I currently have a table Telephone
it has entries like the following:
9073456789101
+773456789101
0773456789101
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.
I recently solved a similar problem with a combination of RIGHT(), LEN() & PATINDEX(). PATINDEX will return the integer 1 when it finds a 9 as the first character and 0 otherwise. This method allows all records to be returned at once without a CASE WHEN statement.
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.SQLFiddle DEMO
Result will be "EST"
Here is the code and a SQLFiddle