substring, replacing format

94 Views Asked by At

hello i have row of data 1000 records, that i need to replace and substring in the format like below:

i have this format 004320487091 and i need to convert it to 0.432.487.091 any thought any helps please?

2

There are 2 best solutions below

0
Pரதீப் On BEST ANSWER

If the string is always going to be same format as mentioned in your question then try this. Use STUFF Function to get the result.

select stuff(stuff(stuff(stuff('004320487091',3,0,'.'),7,1,'.'),11,0,'.'),1,1,'')
3
Dudi Konfino On

you can use concat plus substring like that

SELECT concat(substring('004320487091',2,1)
,'.',
(substring('004320487091',3,3))
,'.',
(substring('004320487091',7,3))
,'.',
(substring('004320487091',10,3)))