Skip to content
Advertisement

How can I add a character into a specified position into string in SQL SERVER?

I have a varchar field like:

195500
122222200

I need to change these values to:

1955.00
1222222.00

Advertisement

Answer

If you want to add a ‘.’ before the last two digits of your values you can do:

SELECT substring(code,0,len(code)-1)+'.'+substring(code,len(code)-1,len(code))
FROM table1;

sqlfiddle demo

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement