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?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • 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, '.');

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

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

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