How to convert number to string and append with leading 0

  • zxmgh

    SSC Eights!

    Points: 911

    Hi,

    I try to convert a number to a n lengh string with leading 0, please help.

    25 -> '00000000025'

     

  • Ninja's_RGR'us

    SSC Guru

    Points: 294069

    SELECT RIGHT(REPLICATE(`0`, 11) + CONVERT(VARCHAR(11), YourNumberColumn), 11) AS FormattedColumn FROM dbo.YourTable WHERE ...

  • SwePeso

    SSC-Dedicated

    Points: 39693

    SELECT REPLACE(STR(25, 11, 0), ' ', '0')

     


    N 56°04'39.16"
    E 12°55'05.25"

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

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