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
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • 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
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

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

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