convert string + add '.'

  • Hello Please help me (how to modify a character string in sql server 2017)

    the question is to convert the number 021548798 to 02.15.48.79.89

    thank you

  • samirca007 wrote:

    Hello Please help me (how to modify a character string in sql server 2017)

    the question is to convert the number 021548798 to 02.15.48.79.89

    thank you

    Where does the 9 in the final 89 come from?

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • execuse me it is 0215487989  to  02.15.48.79.89

     

    it's the same chain

  • samirca007 wrote:

    execuse me it is 0215487989  to  02.15.48.79.89

    it's the same chain

    You need to get STUFFing:

    DECLARE @x VARCHAR(20) = '0215487989';

    SELECT @x
    ,Result = STUFF(STUFF(STUFF(STUFF(@x, 3, 0, '.'), 6, 0, '.'), 9, 0, '.'), 12, 0, '.');

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply