Pirvu Georgian Pirvu Georgian - 15 days ago 6
SQL Question

Replace first occurance of '.' in sql String

Let's say we saved inside a

table
the following values on
Column
as
String
:

Select ValuesT from TableT;

ValuesT
-9.827.08
-9.657.40
-80.000.00
-8.700.00
-8.542.43
-8.403.00


How could be replaced with nothing only the first occurance of '.' (dot) from the string?

Ex: for
-9.827.08
should be
-9827.08


I tried with
stuff
function but this won't work for
-80.000.00


select stuff( ValuesT ,3,1,'') from TableT

Answer

Use STUFF function

Find the first occurance of . using CHARINDEX and remove it using STUFF

SELECT STUFF(valuesT, CHARINDEX('.', valuesT), 1, '')
FROM TableT
Comments